[Javascript] How do I remove a substring from a given string?


I want to remove a substring from a given string. How can I do that in Javascript?

1 Answer

3 years ago by

Use replace() method to remove a substring from a given string. For example, if you want to remove test from the string This is a test message

let str = 'This is a test message';

console.log(str.replace('test',''));

Run here https://onecompiler.com/javascript/3xns3qpss

3 years ago by Meera