Loops


#1

Instructions:
Instructions
1.
Let's replace your current code with a loop.

Write a for loop that loops through your vacationSpots array.

Inside the block of the for loop, use console.log to print each item in the vacationSpots array.

CODE:

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

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

Error:
Did you console.log vacationSpots[i] within the for loop?

Can someone please help? I do not understand my error.


#2

Did it say to add this?

As far as errors, it works and looks fine to me.


#3

Nope it didn't say to add that, I just though I might throw it in, but it was causing the problem I was having. Thanks for helping! =)


#4

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