Exercise 11- loops and arrays


#1

hey, I don't understand why I succeeded in the exercise ? i wrote more than 4 cities and the for loop was up to 4 (i<cities.length) so was it suppose to show only 4 cities when i printed it, ot to have an error?


#2



What is your code?

EDIT: If you kept (code)cities.length(code) in (code)for (var i = 0; i < names.length; i++)(code) then it will keep all of the cities even if you have more then 4



#3

does the limitation i < cities.length; should have stopped the counting at 5? if not, what does i < cities.length; good for?

thanks, this is the code:
var cities = ["Melbourne", "Amman", "Helsinki", "NYC","Raanana","chicago"];

for (var i = 0; i < cities.length; i++) {
console.log("I would like to visit " + cities[i]);
}


#4

the cities.length refer to the number of parameters inside the array cities{}?
i am confuse because when we learnd here about length, it was about the number of characters a word "string" has.