Incorrect result in JavaScript calculation [duplicate]
The value of an input is always a string, so + ends up being string concatenation (“10” + “10” is “1010”, as opposed to 10 + 10 which is 20). If you’re using an input type=”number” (the OP isn’t, but others finding this answer may) and the browser supports them, you can use valueAsNumber instead: … Read more