how to use the replace method in javascript

JavaScript
let string = 'soandso, my name is soandso';

let replaced = string.replace(/soandso/gi, 'Dylan');

console.log(replaced); //Dylan, my name is Dylanvar res = str.replace("find", "replace");var str = "Mr Blue has a blue house and a blue car";

var res = str.replace(/blue/g, "red");
 
Source

Also in JavaScript: