title: How to replace multiple strings with other multiple strings at a time in javascript?
body: <p>I have a string prototype whose code is given below:</p>
  
  <pre><code>String.prototype.replaceAll = function(str1, str2, ignore) { 
    return this.replace(
      new RegExp(
        str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\&lt;\&gt;\-\&amp;])/g,"\\$&amp;"),(ignore?"gi":"g")),(typeof(str2)=="string")?str2.replace(/\$/g,"$$$$"
      ):str2
    )};
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>var a = "I am Javascript";
  console.log(
    a.replaceAll("am", "love")
  ); // =&gt; I love Javascript
  </code></pre>
  
  <p>But when it comes to multiple exchange of characters or words, I have to run the prototype multiple times to achieve it. But I have thought of something like this:</p>
  
  <pre><code>  var a = "I am Java";
    console.log(
      a.replaceAll(["am" , "Java"], ["love", "Javascript"])
    ); // =&gt; I love Javascript
  </code></pre>
  
  <p>So can you help me to achieve it? Or there is any other alternative?</p>