12. Loops and Arrays II


#1


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

Having a bit of trouble. The log displays "I know someone called undefined". I get this message:

"Oops, try again. Your code should have printed 'I know someone called linz', 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 = ["linz", "steve", "heather", "roger", "kylie"];
for (var i = 0; i < names.length; i ++);
    console.log("I know someone called " + names[i]);


#2

Be sure to write the correct syntax as required in a for statement. Note the differences below:

for (var i = 0; i < names.length; i++) {
    // code
}

There is no semi-colon permitted where you have one, and the code block { } is required.