Answer the question
In order to leave comments, you need to log in
How to sum thousandths in javascript?
I'm trying to sum through javascript with thousandths, example:
173.206 + 0.007 , for some reason I get 173.007, what could be the problem?
jsfiddle.net/tbjvcw1r/1
Answer the question
In order to leave comments, you need to log in
replace parseInt with parseFloat :var value1 = parseFloat($(".value").text())
What does parseInt do?
• Parses the string, from the beginning, until it encounters a non-digit character in its path.
And the point is.
You have two options:
Use parseFloat , which works like parseInt , but takes fractions into account.
Or use a unary plus to convert a string to a number, but if the string is invalid, this will return NaN:
22 + +"22.18"; // 44.18
+"22lol"; //NaN
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question