4. How does a function work?


#1



https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/4?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: Unexpected string
Oops, try again. There was a problem with your syntax.


// Write your foodDemand function below.
// Last hint: In your reusable block of code, end each line
// with a semicolon (;)
var foodDemand = function("food") {
    console.log("I want to eat" + " " + food);
    foodDemand("cake");


#3

var foodDemand = function("food") {
console.log("I want to eat" + " " + food);
}; //you should close the function before call it
foodDemand("cake");


#4

I have done this.
var foodDemand = function(food) {
console.log("I want to eat""+""+food);
};
foodDemand("chicken");
And it says this:
SyntaxError: missing ) after argument list
Don't know what the problem is.


#5

You have lots of " " here this should look like

console.log("I want to eat" + " " + food);

#6

Thank you benjnev. I will try again tommorow.


#9

do like me step by step :
var foodDemand=function(Food) {
console.log("I want to eat" + " " + Food);
};
foodDemand("ice cream");
and here you go !


#10

i check this mistake, but not clear the ERROR

console.log("I want to eat" + " " + food);


#11

What error message are you getting?


#12

Thank you for the explanation!!


#13

i have this exact thing written and i'm still getting a syntax error