I'd like for something like 5 + 6 to return "56" instead of 11.
views:
201answers:
6
+12
A:
Use "" + 5 + 6 to force it to strings. This works with numerical variables too:
var a = 5;
var b = 6;
alert ("" + a + b);
Kinopiko
2009-11-12 16:57:25
Ok so, suposing the values 5 and 6 are in two variables:var1 = 5;var2 = 6;will it still work
Heidi
2009-11-12 17:03:03
Yes, that will work. I've edited the answer to demonstrate.
Kinopiko
2009-11-12 17:03:51