Further learning


Introduction to 'For' Loops in JS - conclusion

hi - can you please tell me what is wrong here? I get no error. It just says "great - move to next lesson!" Or whatever. I am trying to put my learning together and adding an if / else myself.

var goodMates = ["Cat", "Mick", "Rhodri", "Kate", "Chris"];

for (var i = 0; i > goodMates.length; i ++)

 if ([i] === "Chris") {
  console.log("I am really lucky to have such a good mate as" + " " + goodMates);
     console.log("I am really lucky to have  a good mate like" + " " + goodMates);   


Here, you have it set to only run when i is greater than the length of goodMates

[i] will only be a number, you would want to use arrayName[index-number]

If you want this to print a single name, you'll also want to call a single index item with goodMates[index-number]


Thanks man, I'll have a good think about this and go through the course


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