1. How do functions work? HELP, PLEASE!



<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>


Replace this line with your code.

<do not remove the three backticks above>


Help us out, please. What lesson is it that you are having trouble with? Please post a link and any attempts you have made, thus far. Thank you.


ok, I will get that in there in a second


var foodDemand = food() {what do I put after this?

Here are the instructions

  1. Declare your function and call it foodDemand.
  2. You can call the parameter anything you like. But we’ll call it food because that is the thing that is going to change each time we call the function.Your reusable block of code follow this. 3. Surround it with the right brackets. The code you want to repeat is: console.log(“I want to eat” + " " + food);
  3. Call the function and put in a specific food you want!


To declare (define) a function, we write,

var foodDemand = function () {


This defines the body of the function as being everything written inside the braces, { // code }.

A parameter is a locally defined variable we write to be a holder of the value we pass in to the function.

var foodDemand = function (food) {


The food variable is arbitrarily named, as mentioned above. It helps if we use a name that describes the meaning or purpose of the variable. Here, the author chose food for this reason.

Next we will write the code that goes in the function body; that is, the code snippet that we wish to be able to re-use at any time (the goal of a function is to be re-usable).

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

Note that above the output contains some fixed text (a string literal that does not change) concatenated to our variable (the text that changes with each call to the function).

Finally we call the function with some text to represent the food:

foodDemand("fried chicken");

The output to the display will read,

I want to eat fried chicken


Thank You. I understand it now.