[HELP]- 12/13 (Loops and arrays II)


I've written:

var names= ["name1","name2","name3","name4","Name5"];
for (var i=1; i>names.length; i++) {
console.log ("I know someone called " + names[i])

But is says:
Oops, try again.
Your code should have printed 'I know someone called name1', but
didn't. Make sure to type the 'I know someone called ' part exactly
right, and don't forget the space between that phrase and the name!

Could anyone say what's wrong?


Hi there @andrecdch,

you need to set i equal to 0, so it can start at the beginning and not skip "name1".
then you need to set i > name.length to i < name.length


Thanks! It worked.
I don't understand why should the loop end when 'i' is smaller than length of the array name, since we set 'i' to 0. This way, the length (5) will be greater than 0, and it will stop the loop...

By the way, could you clear my other doubt?


Hi there @andrecdch, I posted a solution to your question. Hope it helps :smile:
click here to see it ---> http://discuss.codecademy.com/t/help-5-7-your-second-for-loop/17480

var names["Felyne","Nelle","Leander","Florinz","Carolien"]
for (var i=0;i<names.length;i++){
    console.log("I know someone called"+" "+names[i])};

Does anyone sees my fault?


hi, you need to add (:wink: on the end of your closing. like this :smile:
var names["Felyne","Nelle","Leander","Florinz","Carolien"];
for (var i=0;i console.log("I know someone called"+" "+names[i]);};

and after you fix that it will run.