How does a function work? 4/13


SyntaxError: Unexpected token cannot find substring u didnt put in a food demand function

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


It would look like you need your foodDemand outside of your function since you are calling your function.

Also this semicolon will cause you problems as well. Get rid of it!


so like put the function on the outside of the
foodDemand ("Noodles") (so here)
i got rid of the semicolon


Did you get another error or did that solve it for you?


another error u didnt print anything


Post your code again for me please and I will paste it into my lesson to look at it. I got that error when I was removing stuff in my code to see where the error was coming from so I am not surprised that error showed up.


ok its right here

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


Ok I am sorry. Apparently I was not clear enough when I said move your calling outside of the function. You don't have to create another foodDemand. Your foodDemand("Noodles") is the correct function call. However, when calling a function, it has to be outside the actual function. The function is between the { } . Therefore, you need to move foodDemand("Noodles"); outside of the } and get rid of the foodDemand you just added. Here is the basic format of how your code should look with the correct calling place:

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

Mine is a little bit more spaced out than yours but that shouldn't matter here.


thx i will try that since im in this kinda class have a wonderful day


You too! I hope it goes well for you in the class! :thumbsup:


it worked
thx for the help


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