javascript (+) sign concatenates instead of giving sum? [duplicate]

Here value gives you a string, hence the concatenation. Try parsing it as an Number instead:

var sum = parseInt(numberOne) + parseInt(numberTwo);

See the demo fiddle.

Leave a Comment