<html>
<body>
<p id="demo">Click the button to display the first character of a string.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var str="HELLO WORLD";
document.getElementById("demo").innerHTML=str.charAt(0);
}
</script>
</body>
</html>