How does a function work?


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




What is the problem you're experiencing? Please follow the template that newtopic gives you it makes it easier for people to assist you.


But I found your issue anyway.

var foodDemand = function(food);
console.log("I want to eat" + " " + "food");
//3. your }; should be here!

foodDemand("Burrito"); <--- 2. The way you have it right now the program is trying to call your function inside your function, which won't work. So make sure that the }; is at 3.

}; //<---1. this should be after your console log statement.


var foodDemand = function(food)
return ("I want to eat" + " " + food);



// This is working for me...


Yup. You basically needed to take the foodDemand() and put it olputside of the foodDemand function.


Thank you guys , yeah it was my mistake.

You can't declare and call the function betwen curly braces.


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