-1

I am just starting to learn programming and I am learning through codeacademy.com but I am stuck on this problem that they gave me. When I input this function like they told me to it gives me a syntax error. Any help is appreciated

// 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 ("Pizza");
  • Your answer already in here. http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname – 0xdw Apr 26 '16 at 14:08
  • Learn from this. https://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/ – 0xdw Apr 26 '16 at 14:15

2 Answers2

0

It looks like you meant to write var foodDemand = function(food){...} without quotes around "food". Otherwise, in your console.log you're passing in a variable, food, that has not been defined.

Ricardo Reyna
  • 574
  • 6
  • 15
-1

Your syntax is wrong. Check some documentation about functions in JavaScript: here

vpenkoff
  • 15
  • 3