Below JavaScript code shows how to replace the given string:-
<script type = "text/javascript">
function ReplaceString()
{
var string1,string2;
string1 = "Replace string using C#";
string2 = string1.replace("C#", "JavaScript");
alert(string2);
}
</script>