12/13: need some help


#1

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

I get this error: SyntaxError: missing ) after argument list. Anyone knows how to fix this?


#2

@sonnguyen1-

Your console.log command should be inside the curly braces in the for loop, not in the parentheses part. Inside the parentheses is where the counter variable (i) is defined and structured. Any commands to be run go inside the curly braces { } of the loop.

So the first line of the for loop should look something like this:

for (var i=0; i < numberToCountTo; i++)

to increment i by 1 each time the loop is run.


#4

sorry, my bad for copying the incomplete code. I have fixed it. Can you have me to solve the problem above?


#5

@sonnguyen1 on this line:

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

you need a + before names[i].


#6

// Click on "Stuck? Get a hint!" if you get stuck!

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

This one not working either I get
SyntaxError: Expected ';'


#7

@imstilldadaddy on your first line

var names["Kevin", "Sherrilee", "Joe", "Amber", "God"];

you need an = between names and [.


#8

done that, now says "unspecified error"??


#9

Are you supposed to be using specific names, or have the output appear a certain way? The code itself works fine, but maybe the output isn't what the exercise is asking for.


#10

@freginold
I add + before names[i] but it doesn't work.
Now the error is : Your code should have printed 'I know someone called a', 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!


#11

@sonnguyen1 the code works fine, the issue is with how the output appears. Are you supposed to use the names they provided you? Do you need a period on the end of the sentence? The code itself executes, it's just not showing exactly the output they are looking for.


#12

@freginold thanks for your help. I get it


#13

its all working fine now, must have just needed refreshing


#14

It needs to be var names = [