Are you adding 2 and 2 together and getting 22? It’s a common problem with adding numbers, especially if the numbers are being passed via a user’s input in a textfield.
The problem here is that the numbers are being treated as strings and doing something like below will result in the incorrect result being output:
var number_one_to_add = document.form1.number_one.value; var number_two_to_add = document.form1.number_two.value; alert(number_one_to_add + number_two_to_add);
var number_one_to_add = parseInt(document.form1.number_one.value); var number_two_to_add = parseInt(document.form1.number_two.value); alert(number_one_to_add + number_two_to_add);
In doing this we now get the correct answer.