Home / Javascript Tips Generated By ChatGPT / Replacing Text in a String in Javascript Use replace to substitute parts of a string. Source Code let greeting = 'Hello, world!'; console.log(greeting.replace('world', 'JavaScript'));