Html page:
<button onclick="myFunction()">Try it</button>
JavaScript Page:
<script>
function myFunction() {
var str = "HELLO WORLD";
var res = str.charAt(0)
document.getElementById("demo").innerHTML = res;
}
</script>
Output:
H
<button onclick="myFunction()">Try it</button>
JavaScript Page:
<script>
function myFunction() {
var str = "HELLO WORLD";
var res = str.charAt(0)
document.getElementById("demo").innerHTML = res;
}
</script>
Output:
H
No comments:
Post a Comment