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


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-NhsaT/2/4?curriculum_id=506324b3a7dffd00020bf661


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]);
}


#2

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


#3

Thank you,

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


#4

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