Ganti semua ocourrences di JS

let str = 'hotdog dog'.replace(new RegExp('dog','g'), 'cat');
console.log(str) //output: hotcat cat
Juan Gabriel