12. Loops and arrays II


#1


12. Loops and arrays II


I'm having trouble getting this to work, it prints the first line of item in the names array, but won't print the rest. I'm staring at it and unable to figure out what i'm doing wrong :frowning:

var names = ["Tom", "Adam", "Warren", "James", "Ian"];

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


#2

the semi-colon after after i++ interrupts the loop, remove it.

your loop condition:

i < names

how does comparing a number an array work? Maybe you need to use the arrays length?


#3

Thank you!

Been banging my head against my desk for hours on this one.


#4