Ok so I have a do-while loop using jQuery. Basically its point is to check to see that there's a photo in the directory and add it to an array. The directory's photos are all named 'phone01.png', 'phone02.png' etc and they're in a directory called 'slides'.
Here's the code:
var images = [];
var i=0;
do {
++i;
$.get('./slides/phone0' + i + '.png',function(){
images[(i-1)] = './slides/phone0' + i + '.png';
});
}
while ( images[(i-1)] == './slides/phone0' + i + '.png' );
So if I use a console at the end, images[] only contains './slides/phone01.png', BUT
i is 1
images[(i-1)] is therefore './slides/phone0' + i + '.png'
Entering ( images[(i-1)] == './slides/phone0' + i + '.png' )
returns true
. So the while statement is true, but the loop is not continuing.
Moreover, if I manually run the loop again (iterate i, run the get) the get will succeed and add a new member to the array. So, the do function never runs a second time.
What gives?