Syntax error: unexpected token (


#1

Every time I try to enter what I think is correct, the error message that the console keeps giving me is "syntaxerror: unexpected token (" I haven't got the faintest idea of what this is supposed to mean, and I would very much appreciate advice and help. thank you!

var foodDemand = function(food) {
console.log("I want to eat" + " " + food);
    }
    function("pie")

#2

Notice anything? You are missing the semicolon at the end of the curly brace for your function, and you are also missing the semicolon when calling your function.


#3

thank you very much for the advice, but adding a semicolon at the end of the curly brace and the end of the call still spits the error message listed above.


#4

Did you make sure that it looks like this?

var foodDemand = function(food) {
console.log("I want to eat" + " " + food);
};

 function("pie");

Could I also get a link to the exercise?


#5

you have to end with the var name("whatever");

foodDemand("whateverYouWantToPutHere");


#6

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

};
nameString("dj");

SyntaxError: Unexpected token )


#7

Hello,
I have the same problem of Syntax error: unexpected token...
Do you know where is the error?

var greeting = function (name) {
console.log("Great to see you," + " " + name);
};

// On line 11, call the greeting function!
var greeting = function(name){
console.log("Hello" +" "+ name);
};
function("name");

Thanks to all


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.