+ 1

Why the output is 8800481086, why not 169090?

var a ="88004"; var b="81086"; alert(a+b);

14th Jun 2017, 8:03 AM
Banti Kumar
Banti Kumar - avatar
2 Answers
+ 2
Because you are concatenating two strings instead of adding two integers. Imagine adding two words together: "one" + "two". The answer would not be "three" because those are words, not numbers. The answer is "onetwo." If they are integers: 1+2 = 3.
14th Jun 2017, 8:09 AM
Joseph P French
Joseph P French - avatar
+ 2
Thank you so much Joseph for your quick reply and explaining with example. thank again😊
14th Jun 2017, 8:17 AM
Banti Kumar
Banti Kumar - avatar