title: Javascript += equivalent?
body: <p>My code is a simple function that checks which radio button was pressed, and adds the value of that radio button to my <code>var input = 0;</code>. However, I know I am doing something wrong as it works but the output is wrong. When one of the <code>if</code> statements is true, instead of input(0) now being equal to itself plus the new value of the <code>getElementById("small").value</code>, it prints out <code>010</code> as opposed to the now <code>10</code>.</p>
  
  <p>I know in Java there was a convention similar to <code>input += getElementById("small").value;</code> but this doesn't seem to work. So as you can see in my example below, I tried the alternative of <code>input = input + /*code*/;</code> but still no luck.</p>
  
  <p>I am new to JavaScript but very familiar with Java. I imagine I'm just using the wrong syntax here but all my Google searches are a bust.</p>
  
  <pre><code>function calculate()
  {
      var input = 0;
      if (document.getElementById("small").checked) 
      {
          input = input + document.getElementById("small").value;
      }
      else if (document.getElementById("medium").checked)
      {
          input = input + document.getElementById("medium").value;
      }
      else if (document.getElementById("large").checked)
      {
          input = input + document.getElementById("large").value;
      }
      else
      {
          alert("failed");
      }
  
      document.getElementById("outar").innerHTML = input;
  }
  </code></pre>