March 24th, 2013, 03:01 AM
Concatenation vs addition, help appreciated
a = prompt("a =");
b = prompt("b =");
c = prompt("c =");
result = a + b + c;
My problem is that
concatenates the values instead of adding them; I searched and found that applying parseInt(variable) fixes this and tried it with success, but I was wondering if there is a simpler way, a function that performs "result = a + b + c" with addition rather than concatenation. I've tried various incarnations of "result a + b + c" and haven't been able to overcome this.
I appreciate any advice and thank you for reading this post. I also apologize if this question has been broached before.
March 24th, 2013, 04:26 PM
Using parseInt is the correct approach.