12/13


#1

This is my code
var names = ["Josh", "Jake", "Joe", "July", "Bob"];
for (var i = 0; i < names.length; i++);
{
console.log("I know someone called " + names [i]);
}

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

Any ideas on how I can fix it?


#2

Edit there is no space between names and [i]. it looks like names[i]


#3

You don't need that semicolon at the end.


#4

Hello,
The corrector thing keeps on saying this to my code "Oops, try again.
Your code should have printed 'I know someone called Sarah', 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!"

Here is my code and I hope you can help me.

// Click on "Stuck? Get a hint!" if you get stuck!
// camillita's reply: "Okay, let's do this!"  
var names = ["Timothy", "Ana Carina", "Sophia", "Heloise", "Sarah"];

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

Thanks :relaxed:


#5

Jepp because your loop runs four times and not five times.

i < 4 //add a =

#7

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

Any idea why i'm not getting a space? If i surround the + in quotes it says i'm missing a parenthesis. quite boggled.


#8

Hi,

do a whitespace before the quote:

Your Code

"I know someone called" + names[i]

Corrected code

"I know someone called " + names[i]

#9

Worked very well thank you!