How does a function work?


#1


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


foodDemand("Burrito");

};


#2

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


#3

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.


#4

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

}

foodDemand("Burrito")

// This is working for me...


#5

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


#6

Thank you guys , yeah it was my mistake.

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


#7

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