var variableABC = \"A B C\";
variableABC.replace(\'B\', \'D\') //wanted output: \'A D C\'
but \'variableABC\' didn\'t change :
If you just want to clobber all of the instances of a substring out of a string without using regex you can using:
var replacestring = "A B B C D"
const oldstring = "B";
const newstring = "E";
while (replacestring.indexOf(oldstring) > -1) {
replacestring = replacestring.replace(oldstring, newstring);
}
//result: "A E E C D"