title: JS replacing all occurrences of string using variable
body: <p>I know that <code>str.replace(/x/g, "y")</code>replaces all x's in the string but I want to do this</p>
  
  <pre><code>function name(str,replaceWhat,replaceTo){
      str.replace(/replaceWhat/g,replaceTo);
  }
  </code></pre>
  
  <p>How can i use a variable in the first argument?</p>