Javascript replace function only working once for a String ?

#2
<script type="text/javascript">
var visitorName = "Chuck";
var myOldString = "Hello username! I hope you enjoy your stay username.";
var myNewString = myOldString.replace(/username/g, visitorName);

document.write("Old string = " + myOldString);
document.write("<br />New string = " + myNewString);

</script>
 
Top