Loops and arrays II Error


#1

Hi Guys,

I hate to be a pain, really I do, but I need assistance. I've attempted to add / delete spaces and semi-colons but whatever I do I cannot get my code to work for this assignment. Can I please get another set of eyes to look at this to see what I'm doing wrong? Thanks in advance!!

~Eva


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

Oops, try again. Your code should have printed 'I know someone called Eva', 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 = ["Eva","Chris","Putters","Cady","Angela"];

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

#2

It's due to this. You need to write names.length as you want to loop up to the length of names. You will get a error if you just write names.


#3

You're a genius. I thought I did that but I must've deleted it. You've solved my issue.
Thank you!


#4

Haha, no worries man.


#5

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