Loops and Arrays II - syntax error


#1

var names = ["Dana","Xander","Joseph","Thomas","Steve"];
for (var i = 0; i < 10; i ++)
{
console.log("I know someone called " names[i] ".");
};

This is driving me nuts..I keep getting the error: SyntaxError: missing ) after argument list

I'm sure it's me missing something very small, but I just can't figure it out..


#2

Hi @smondaca

Don't worry, just change your line 4 to have this :

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

Hold on :wink:


#3

oh man...I knew it would be something so simple. lol..thanks for the help!


#4

Bugs are often induced by those little mistakes :sweat_smile:


#5

for (var counter = 1; counter < 11; counter++) {
console.log(counter);
}


#6

@crt_mihai, If you're going to use "counter" as your variable, then the console.log should be:

console.log(names[counter]);