Please help 12. Loops and Array 2


#1

var names = ["Paolo", "Giovanni", "Elisa", "Luigi","Carla"];

for (var i = 1; i <= 1; i++) {
console.log("I know someone called " + names[i]);
}

I did this because I sow array position rules.
What's wrong?


#2

In your for loop, you'll need to change i = 1 to 0.

Remember that JavaScript counts in base 0. Meaning position 1 in your array is '0', position 2 is '1', and so on. Your current code starts with i = 1, which means "Giovanni" will be the first string to print, and in this exercise we want all five names to print.

Also, in the second step of your loop, you have i <= 1. This is a problem because if i = 1, your loop will only run once, and we want it to loop through your entire array. So, let's make i < names.length. This will ensure that we keep scanning our array so long as there is content to scan.


#3

Thanks a lot I didn't understand the exercise. I put the number 1 because he told me I had to write I know someone called Giovanni.......................with your answer now it work. tanks