Loops and arrays II


Hello.I'm a Japanese Univercity student.
I can't solve it.

var names =["Alice","Mark","Jef","Moon"];
for(int i = 0;i < names.length; i++){
console.log("I know someone called" + names[i]);

The message is

SyntaxError: Unexpected identifier


Hi inside your for loop this part

int i = 0;

Should be var instead of int


Please read the instruction carefully:

01. Create an array called names filled with 5 names.
02. Write a for loop that prints "I know someone called " followed by names[i]. Make sure there's a space between "called" and the name!

make you array holds five value.

and try to change the int to var

and one more thing, add spaces between called and "" , like this: I know someone called " not I know someone called"

Hope this helps


This comes across quite confusing, what she's trying to say is add " " which is a space after "I know someone called" like I have shown below.

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


Naaah, sorry. Its a typo error.

Write this line like this:

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

instead of

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

See the difference? Its on the called" and called ". See the space between called and double quote?


Yes but that would add 2 spaces one after called and one by "adding" a space +" "+ but the exercise requires only one so either the one after called or the added one.


Sorry my fault. i already edited my reply post.
@meinakazato hope this time, you got it right and your codes run smoothly :slightly_smiling:



Thank you everyone.
I can't notice the mistake!



var names=["Alice","Katie","Ellie","Bertie","Will"]     
for(var i = 0; i < names.length; i++) {
console.log("I know someone called" + " " + names[i]);

Try that