Display the position of the first occurrence of "World" in the variable txt. - Javascript String

Javascript examples for String:Quiz

Description

Display the position of the first occurrence of "World" in the variable txt.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
var txt = "Hello World";
document.getElementById("demo").innerHTML = txt.indexOf("World");
</script>//from  ww w. j av a2s.  c  om

</body>
</html>

Related Tutorials