var str = "JavaScript replace method test";
var res = str.replace("test", "success");
//res = Javscript replace method success
var string = "golden vigor doers goat";
var replacedString = string.replace("go", "GO");
console.log(replacedString);
str.replace('tobereplaced', 'replacement'),
let text = "I love you"
text = text.replace( / +/g, '_') // replace with underscore ('_')
console.log(text) // I_love_you