title: How to add two values in javascript
body: <p>This is a simple dropdown with values. I'm trying to pull the values as currency then add.</p>
  
  <p>The values aren't being added (<code>1+1=2</code> or <code>1+2=3</code>) but instead are concatenating (<code>1+1=11</code> or <code>1+2=12</code>). Where am I going wrong here?:</p>
  
  <pre><code>&lt;script&gt;
      function displayResult()
      {
          var strm=document.getElementById("matt").options[document.getElementById("matt").selectedIndex];
          var t=strm.text.search("\\\$");
          var strb=document.getElementById("box").options[document.getElementById("box").selectedIndex];
          var b=strb.text.search("\\\$");
          var x=strm.text.substr(t+1);
          var y=strb.text.substr(b+1);
          var math= x + y;
  
          alert(strm.text.substr(t+1));
          alert(strb.text.substr(b+1));
          alert(math);
      }
  &lt;/script&gt;
  
  &lt;form&gt;
      Select #1:
      &lt;select id="matt"&gt;
          &lt;option&gt;$1.00&lt;/option&gt;
          &lt;option&gt;$2.00&lt;/option&gt;
      &lt;/select&gt;
  
      &lt;br /&gt;
      Select #2:
      &lt;select id="box"&gt;
          &lt;option&gt;$3.00&lt;/option&gt;
          &lt;option&gt;$4.00&lt;/option&gt;
      &lt;/select&gt;
  
  &lt;/form&gt;
  
  &lt;button type="button" onclick="displayResult()"&gt;Display index&lt;/button&gt;
  </code></pre>