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"));
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"));