# For loop backwards

#1
https://www.codecademy.com/courses/learn-javascript/lessons/loops/exercises/for-loop-ii?action=lesson_resume

The instructions state the following…
We need to make three changes to our for loop:
Edit the start condition (var i = 0), to set i equal to the length of the vacationSpots array.
Then, set the stop condition ( i < vacationSpots.length) to stop when i is greater than or equal to 0.
Finally, change i++ to i-- to subtract 1 from i each loop.

QUESTION–If the stop condition is EQUAL OR GREATER THAN 0, then when the the for loop begins, the variable is already GREATER than 0 so why does it continue? CAN SOMEONE EXPLAIN THIS?

``````
var vacationSpots = ['Paris', 'New York', 'Barcelona'];

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

``````

#2

The misnomer is that this is the stop condition, when that is not the case. It is the `while true keep running` condition. As long as `i` is greater than or equal to 0 the loop will continue to iterate.

#3

As a beginner, most of the challenge is grappling with terminology. There must be a reason for the less than intuitive name of “stop condition”… Anyway, you quick concise explanation is appreciated!
Darryl

#4

Thank you! This helps SO much!

#5

Hi, this is a simple task yet uncompletable (apparently). Its asking me to create a variable titled ‘myplaces’ and set it equal to 3 arrays of places i would like to visit. can anyone review both sets of my code and explain to me where i might be going wrong?

ive tried both the default code and attempting it from scratch with my own code.

thankyou

#6

instructions set

#7

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