Replace part of a string:
let text = "Hello World"
console.log(text.replace("World", "JavaScript"))
// "Hello JavaScript"
By default, replace() only replaces the first occurrence:
let text = "cat cat cat"
console.log(text.replace("cat", "dog"))
// "dog cat cat"
To replace all occurrences, use replaceAll() or a regular expression with the global flag.