title: Javascript Math Erroring
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8377410/addition-is-not-working-in-javascript">Addition is not working in JavaScript</a>  </p>
  </blockquote>
  
  
  
  <p>So I've been working on a calculator of sorts for a game I play. I have the formula below to work it out, however, it's stringing the values together instead of actually adding them. So, if I put nothing in, I get "000000000000000000000000" for the value, and if I change totalattack to a 1 I get "10000000000000000000000". Having looked around a bit, I'm really not sure why it's doing that. Or how to fix it. </p>
  
  <pre><code>var invasionattack = totalattack + (600*DSC) + (60*translator) + (35*mindcontrol) + (30*psionic) + (40*mutagen) + (2500*cartridge) + (300*stryll) + (15*mech) + (20*bane) + (30*cbane) + (60*hbane) + (45*obane) + (75*mbane) + (decimator*200);
                  alert('Invasion Attack From Modules: ' + invasionattack);
  </code></pre>
  
  <p>If anyone is curious/if it's relevant, the full code can be found here:
  <a href="http://glcalc.x10.mx/invasioncalc.html" rel="nofollow noreferrer">http://glcalc.x10.mx/invasioncalc.html</a> then view source. </p>
  
  <p>There's also a bug with the multipliers somewhere, but I'll find that later. </p>