12. Loops and Arrays II (Your code should have printed 'I know someone called', but didn't)



I think I have typed the message in a correct way, but I get the following error:

Oops, try again. Your code should have printed 'I know someone called Andre', 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!

var names = ["Andre", "Jaap", "Joost", "Jan", "Janneke"];

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


Hi your for loop

for (var i = 0; names.length < 5; i++)

you define a variable i so you should use it here

names.length < 5

instead of 5 put i.
Then you should change the < with > because like that it will be an infinit loop


Thank you,

I now see what I have done wrong. It is simple, but you have to see it!


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