4. For loops backwards: Question re stop condition


The code below is the correct code to loop a code backwards but I don't understand why the stop condition is ">=". Shouldn't it be ===? Because "i" will always be greater than or equal to 0 even at the start since it starts at 2 here.

Any help would be appreciated! Thanks!

Replace this line with your code. 
var vacationSpots = ['Paris', 'New York', 'Barcelona'];

for (var i = vacationSpots.length - 1; i >= 0; i--) {
  console.log('I would love to visit ' + vacationSpots[i]);


If it was for stopping and it is true at the start, then the outcome would be that it doesn't loop. Since your code does loop, that can't be what it is. (What you're saying doesn't add up, you need to go back a couple of steps in your reasoning)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

"4. for loop backwards" Greater than?