JavaScript program to replace all occurrences of a character in a string with another character:

python tutorials and learn python

Created with Sketch.

JavaScript program to replace all occurrences of a character in a string with another character:

function replaceChar(str, char1, char2) {
  return str.split(char1).join(char2);
}

console.log(replaceChar("javascript is awesome", "a", "o"));

Leave a Reply

Your email address will not be published. Required fields are marked *