I want to be able to combine numbers as strings.
orCode:1 & 2 = 12
The "&" sign does not work. Any suggestions?Code:if (min<10){ min = 0 & min }
| SitePoint Sponsor |
I want to be able to combine numbers as strings.
orCode:1 & 2 = 12
The "&" sign does not work. Any suggestions?Code:if (min<10){ min = 0 & min }




You need to use the "+" instead of the "&" sign.
Chuck Norris is so tough, mosquitos ask for permission before they bite him


You can use the String object, or the toString method to work with them as strings, or just use an actual string.
Code:var a = 1, b = 2, c = String(a) + String(b);Code:var a = 1, b = 2, c = a.toString() + b.toString();Code:if (min < 10) { min = '0' + min; }
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Bookmarks