I need to count numbers from 1 - 999 using three digits output.
Here is what i need:
001
002
003
004
005
006
007
008
009
010
011
.
.
.
099
100
.
.
.
999
Is this possible using javascript or jQuery? Many Thanks.
I need to count numbers from 1 - 999 using three digits output.
Here is what i need:
001
002
003
004
005
006
007
008
009
010
011
.
.
.
099
100
.
.
.
999
Is this possible using javascript or jQuery? Many Thanks.
Yes, just print the numbers from 1-999 with padded zeroes at the beginning when needed.
for(var i = 1; i <= 999; i++) {
console.log(("00" + i).slice(-3));
}
You can see this in action on this jsFiddle demo.