Use the replace() method to replace "World" with "Universe". - Javascript String

Javascript examples for String:Quiz

Description

Use the replace() method to replace "World" with "Universe".

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.replace("World", "Universe");
</script>/*  w  w w.j  a  va  2s .co m*/

</body>
</html>

Related Tutorials