// Loop through cookieString searching for name
// Analysis
for(i=0; i<cookieString.length;)

This is the loop that is responsible for searching for the cookie's name. Notice that the loop does not have any increment operator. The increment operator was omitted because we want to perform a special increment, and then check the value of the increment variable (i) before continuing with the loop.

This section of code could just as easily have been written using a while loop. However, I used the for loop to initialise the variable i and provide the looping mechanism in one step. If you want to re- write the code using a while loop, then by all means do so.

Close Window