title: Javascript Replace value from var
body: <p>Can anyone help me with this script?
  I have to replace the value of a variable in a string (string variables are dynamic)</p>
  
  <p>Here's an example:</p>
  
  <pre><code>var string = "#sport,#fotogallery,#sport,"; 
  var element = "#sport"; 
  string.replace(element+",","");
  alert(string);
  </code></pre>