Javascript Data Type How to - Replace the first comma








Question

We would like to know how to replace the first comma.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--from  w w  w.  j  av  a 2  s. c om-->
    var myString = "some where is something at something, I am, something "
    var temp = myString.replace(",","!");
    document.writeln("Temp is: " + temp);
}
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: