javascript replace first substring in string code example
Example 1: js replace characters in a string
var str = "Original string!";
var str = str.replace("Original", "New");
Example 2: javascript regex replace
const search = 'duck'
const replaceWith = 'goose';
const result = 'duck duck go'.replaceAll(search, replaceWith);
result; // => 'goose goose go'