12/13: need some help


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?



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.


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


@sonnguyen1 on this line:

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

you need a + before names[i].


// 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 ';'


@imstilldadaddy on your first line

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

you need an = between names and [.


done that, now says "unspecified error"??


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.


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!


@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.


@freginold thanks for your help. I get it


its all working fine now, must have just needed refreshing


It needs to be var names = [