title: How to replace multiple keywords by corresponding keywords with the `replace` method?
body: <p>I want to make a content editable div in which I replace explicit words with asterisks. This is my JavaScript code:</p>
  <pre class="lang-js prettyprint-override"><code>function censorText(){
      var explicit = document.getElementById(&quot;textbox&quot;).innerHTML;
      var clean = explicit.replace(/&quot;badtext1&quot;,&quot;cleantext1&quot;|&quot;badtext2&quot;,&quot;cleantext2&quot;/);
      document.getElementById(&quot;textbox&quot;).innerHTML = clean;
  }
  </code></pre>
  <p>Here’s the HTML for my <code>&lt;div contenteditable&gt;</code>:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div contenteditable=&quot;true&quot; onkeyup=&quot;censorText()&quot; id=&quot;textbox&quot;&gt;Hello!&lt;/div&gt;
  </code></pre>
  <p>As you can see, I tried using a regex operator to replace multiple strings at once, but it doesn’t work. It doesn’t replace <code>badtext2</code> with <code>cleantext2</code>, and it replaces <code>badtext1</code> with <code>0</code>. How can I make a single <code>.replace()</code> statement replace multiple strings?</p>