The replaceAll() method in JavaScript replaces all the occurrences of a String and returns it. The original string is left unchanged.
Here’s an example code implementation :
const my_string = “So I said yes to Thomas Clinton and later thought that I had said yes to God and later still realized I had said yes only to Thomas Clinton.”
console.log(my_string.replaceAll(‘yes’, ‘no’));
The expected output: “So I said no to Thomas Clinton and later thought that I had said no to God and later still realized I had said no only to Thomas Clinton.”
If you want to learn more about Java, then go through this Java tutorial by Intellipaat for more insights.