Part 12: Introduction to 'For" Loop in JS Error


Oops, try again. Your code should have printed 'I know someone called Brendan', 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!
I can't seem to find what's wrong. I've looked over it to what feels like 100 times, and this still comes up!
Look, I'm going to feel stupid afterwards...

var names = ["Brendan", "Ike", "Jill", "Winona", "Lance"]

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




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

The second condition should be i < names.length, not i == names.length. The code within the for loop will run as long as the second condition is met. Because i == names.length is currently false, the code will not run.


Ah, I knew I would feel stupid. Thank you very much.


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