Replacing Substrings in a String in Javascript


Use String.replace() to replace parts of a string.

Source Code

let message = "Hello, world!";
let newMessage = message.replace("world", "JavaScript");
console.log(newMessage); // "Hello, JavaScript!"
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments