I've got a loop which returns a list of image sources with incremental values. When testing I was using 4 digit values with leading zeros due to the image src's.
The strange thing I noticed is that if I use a leading zero on the condition in the loop it stops at 398. If I remove this zero it completes correctly.
// Stops at 398
for (var i = 0001; i < 0617; i++) {
$('.target').append('{"src": "IMG_' + i + '.jpg", "id":"image' + i + '"}');
}
// Completes
for (var i = 0001; i < 617; i++) {
$('.target').append('{"src": "IMG_' + i + '.jpg", "id":"image' + i + '"}');
}
Here's a fiddle with a working example
Has anyone got any insight into this behaviour?