Skip to content
Advertisement

How to find and replace a string in Javascript? [closed]

How can I find a specific word in a string then replace it using javascript?

For example

JavaScript

I would like to find the word “sentence” and replace it by “phrase”, so the output would be

JavaScript

Advertisement

Answer

Yes, just use replace:

JavaScript

In the above example, boldTest is whatever word you want to replace.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement