Replacing Text in Strings

The replace() method searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring. When you use the replace method, the method returns a new string containing the results of performing the replacement. The original string is not altered.

Syntax

string.replace(regexp/substr,newstring)

Example

<script type="text/javascript">

var str="Visit Facebook!";
document.write(str.replace("Facebook", "Paktutorial"));

</script>
DOWNLOAD SOLUTION HERE