• Post category:JavaScript
  • Reading time:1 mins read

Today we will show you how to replace multiple strings in JavaScript using Split and Join functions. In the previous article, we explained how to replace multiple strings using Regular Expression.

Use the following code to replace multiple strings using Split and Join method.

function handleReplaceAllSplitJoin() {
  var sentence = 'This is test example and it Is easy to learn.';
  var output = sentence.split('is').join('-'); // Output: Th- - test example and it Is easy to learn.
  document.getElementById("demo2").innerHTML = output;
}

That’s it for today.

Leave a Reply