12. Loops & Arrays II


#1


My code isn't working for some odd reason. I looked at other examples within this Q&A twice.

The error message I'm getting is as follows:

Oops, try again.
Your code should have printed 'I know someone called Kyle', 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!


var names = ["Kyle", "Angel", "Vlad", "Jonna", "Luci"];

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


#2

This will print Kyle five times. Use names[i] to print full list.


#3

names [i] is getting the same result?


#4

Try doing a page refresh and submit again?


#5

i actually got a little closer with a few changes

var names = ["Kyle", "Angel", "Vlad", "Jonna", "Luci"];

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


#6

The for loop has two points of concern:

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

The semi-colon on the first line should be removed. Use names[i].


#7

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