Javascript Code Help?


#1


How does a function work? (4/13)


I was just coding around and this error message popped up.
"Oops, try again. It looks like you didn't put quotes around the food you gave foodDemand! "
I put quotes around "Hamburger", and I think that's what it meant, but it keeps popping up!
*Edit: this was on the code checker screen if it's helpful:"ReferenceError: food is not defined"

// 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);
};
food("Hamburger");


#2

You were so close!

You just need to call your function rather than calling the name you put in the parameter. Call foodDemand rather than food.

You code should look like this.

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

You are getting that error as you have not made food a variable.
I'm sure this threw you off though.

Let me know if you need further explanation.
However If this helped you please mark my reply as the solution :slight_smile:


#3

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