Javascript adding two numbers incorrectly
Posted
by
Scott
on Stack Overflow
See other posts from Stack Overflow
or by Scott
Published on 2010-09-03T17:23:58Z
Indexed on
2011/01/07
21:54 UTC
Read the original article
Hit count: 137
JavaScript
Global.alert("base: " + base + ", upfront: " + upfront + ", both: " + (base + upfront));
This code above outputs this:
base: 15000, upfront: 36, both: 1500036
Why is it joining the two numbers instead of adding them up?
I eventually want to set the value of another field to this amount using this:
mainPanel.feesPanel.initialLoanAmount.setValue(Ext.util.Format.number((base + upfront), '$0,000.00'));
...and when I try that now it turns the number into the millions instead of 15,036.00. I have no idea why. Any ideas?
© Stack Overflow or respective owner