12.Loops and Arrays II Problem


#1


I'm having trouble figuring out what I typed wrong. Could someone help me out? Thanks.


#2

The problem is in your for loop:

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

You are saying while i is greater than the length, but it should be less than.
Change the > to <


#3

Thank you @cadecodes for your solution!


#4

Your welcome! Post again if you have any other questions!


#5

thank you i made the same misstake but you forgot the var.
for( var i = 0; i > names.length; i++)


#6

I don't need the var, as it is being used as a local variable. :slightly_smiling:


#7

okay, of course you are right


#8

tank you I must be blind. and need better glasses.


#9

I changed the > Oops, try again. Your code should have printed 'I know someone called Yaina', 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!for the < and still geting the same answer.

I changed the > for the < and I getting the same message Oops.

// Click on "Stuck? Get a hint!" if you get stuck!

var names=["Yaina","Carlo","Pipito","John","George"];
for(var i=0; i< names.length;i++) {
console.log("I know someone called", " " + names[i]);
}
I know someone called Yaina
I know someone called Carlo
I know someone called Pipito
I know someone called John
I know someone called George


#10

console.log("I know someone called", " " + names[i]);

in this line of code, instead of plus +, you used comma ,.