Error in for loop


#1


Hello, I have done this Exercise but apparently it doesn't accept the space i gave it, i even tried copy pasting, nothing works.

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


var names = ["Name","name2", "name3","name4","name5"];

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


#2

look at your condition:

i>5

i is initialized as zero, so:

0>5

which is false, so the loop never runs. Maybe you need to change your loop condition


#3

thanks, that fixed it.
however the error message displayed was confusing since it refers to the space in the string, not the for loop; hope that helps.


#4

the only relevant part of the error message for you was:

Your code should have printed 'I know someone called Name', but didn't

don't fully rely on codecademy's error messages. Learn to debug and think critical on your own


#5

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