What is wrong with my code? Lesson 3/11


#1

Hey CodeCademy community,
I cannot seem to find the issue with the following code on lesson 3/11:

var nameString = function (name) {
return "Hi, I am"+" "+name;
}
console.log nameString("Sam")

After running this code, I get the following error:

SyntaxError: Unexpected identifier

Any ideas on what's wrong?
Thanks!


#2

Hi try to remove the console.log


#3

I tried that, but then I got the CodeCademy error saying:

Oops, try again. It looks like you didn't print anything to the console! Did you remember to console.log() the result of passing your name to the nameString() function?


#4

I fixed it! I forgot to put parentheses around the material to be printed to the console.

var nameString = function (name) {
return "Hi, I am" + " " + name;
};
console.log(nameString("Sam"))