Search This Blog

Friday, 29 July 2016

How to guess the paragraph first word using javascript?

Html page:

<button onclick="myFunction()">Try it</button>
<p id="P4"></p>

Javascript page:

<script>
    function myFunction() {
        var str = "Hello world, welcome to the universe.";
        var n = str.startsWith("Hello");
        document.getElementById("demo").innerHTML = n;
    }
</script>

Output:

true

No comments:

Post a Comment