JavaScript两数相加(踩坑)记录
Adding two numbers concatenates them instead of calculating the sum
JavaScript里两个变量
var a = 2;
var b = 1;
var c = "(" + a + b +")";
alert(c);
结果输出:(21)
正确写法:
var c = + a + + b;
var d = "(" + c +")";
JavaScript里两个变量
var a = 2;
var b = 1;
var c = "(" + a + b +")";
alert(c);
结果输出:(21)
正确写法:
var c = + a + + b;
var d = "(" + c +")";