Stuck on for loop


#1

hi all i don't know what is the problem with my code ...

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

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

}
out put :
I would love to visit Paris
I would love to visit New York
I would love to visit Barcelona


#2

Can I have the link to this exercise and your error message please?


#3

error message is Did you write the conditions in the for loop's parentheses like the example?


#4

The code is valid. Could you please post the full error?


#5

The problem is the way that you're doing the instructions. In this course, you have to do the instructions step by step.
First, you need to just do

console.log(vacationSpots[i]);

inside of the for loop and press Save & Submit, but then you need to submit the code that you are currently using.
It is overwriting the first instruction so it says you haven't passed it.


#6

i try this but still same problem
code :
var vacationSpots = ['Paris', 'New York', 'Barcelona'];

for (var i = 0; i < vacationSpots.length; i++)
{
console.log(vacationSpots[i]);

}
message :
Did you write the conditions in the for loop's parentheses like the example?


#7

kyleaw ,, the problem solved i think your last solution solve it Thank you :blush:


#8

I'm glad that you passed it, no problem. :slight_smile:


#9

thank for your attention jibblyj my problem solved


#10

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