When I enter my code, it says I did not call foodDemand


Link to exercise:

I think I'm doing my code right, but the computer keeps telling me that I didn't call foodDemand.

My code:

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


This post was flagged by the community and is temporarily hidden.


I entered:

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

and it came up with a false positive. In the box it says:

I want to eat undefined


it did return it, but it came before the sentence and made the word undefined appear.


then I accidentally moved on to the next lesson trying to click the "save and run" button and did it like this:

// Nicely written function:
var calculate = function (number) {
var val = number * 10;

// Badly written function with syntax errors!

var greeting = function (name){


console.log (greeting())

and it came up with another false positive with two "undefined" in the box.


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



make sure to give parameter for the foodDemand function which is food

and define that food parameter with any thing you like. in this case it is ribs


yes, that makes sence. I think the problem in my code was the local and global variables.