To concatenate two numbers as strings,
- Simply add an empty string to it.
Example code:
var num1 = 50;
var num2 = 25;
var concatenatedString = "" + num1 + num2;
*Note: This example will fail JSLint. - Use toString() on any one variable or both.
Example code:
var num1 = 50, num2 = 25, concatenatedString = num1.toString() + num2;
var num1 = 50, num2 = 25, concatenatedString = num1.toString() + num2.toString();
*Note: This code will pass JSLint.