3. help please


#1

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

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

1.. Let's replace your current code with a loop. Write a for loop that loops through your vacationSpots array.


#2

What do you need help with? Are you getting an error message? I don't see any issues with your code.


#3

Yes error Did you console.log vacationSpots[i] within the for loop?

Help exercise Let's replace your current code with a loop. Write a for loop that loops through your vacationSpots array.


#4

Hi dlugamarta, as mtf said your code is correct and i don't know why it is returning an error message. Just try this code below it is the same thing that yours.

var villes = ["Melbourne", "Amman", "Helsinki", "NYC"];

for (var i = 0; i < villes.length; i++) {
    console.log("J'aimerais visiter " + villes[i]);
}

#5

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

Learn JavaScript - Arrays and Loops - Loops - exercise - 3


#6

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