Search This Blog

Thursday, 28 July 2016

How to find the word of given paragraph using javascript?

Html  page:

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

JavaScript Page:

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

Output:

Ture

No comments:

Post a Comment