How could I do this?
1 -> 01
4 -> 04
9 -> 09
11 -> 11
22 -> 22
Thanks!
If you want something flexible:
Number.prototype.pad = function(length){
return (new Array(length - this.toString().length + 1)).join('0') + this;
}
var x = 6;
x.pad(2); // 06
or if you want the basic 2-digit only:
x<10 ? '0'+x : x