how to find and replace all elements from a string in javascript code example
Example 1: js replace all substrings
/// replace "abc" with "" (blank string)
str.replace(/abc/g, '');
Example 2: javascript replace all with variable
/**
*A better method for replacing strings is as follows:
**/
function replaceString(oldString, newString, fullString) {
return fullS.split(oldS).join(newS)
}
replaceString('World', 'Web', 'Brave New World')//'Brave New Web'
replaceString('World', 'Web', 'World New World')//'Web New Web'