title: Using JavaScript's replace() method with global switch on a variable
body: <p>I can't any example of this after being unable to puzzle out how it would work on my own.</p>
  
  <p>All I want to do is take a string which has been assigned to a value, and use that as the replace match string for all matches.</p>
  
  <pre><code>var replacement = 'i';
  var text = 'tieiam';
  
  text = text.replace(replacement, '');  // 'teiam'
  
  text = text.replace(/tieiam/g, ''); // 'team'
  </code></pre>
  
  <p>How do I use them together??</p>