Cannot figure out what is wrong with my syntax


Introduction to Functions in JS (Lesson 4)

It give me an error message that my syntax is incorrect.

// Write your foodDemand function below.
// Last hint: In your reusable block of code, end each line
// with a semicolon (;)

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


Take out the = and space


Just did. Still shows the syntax error.


val also has to go..


Removed that as well.

The error message now says I didn't print anything to the console?


You cannot use space in variable name. You wrote:

var val foodDemand .

Use either val_foodDemand or a single word. Also you did not call the function outside. You did not use the function parameter inside.

var yourfunction_name_without_space = function (parameter) {

console.log("I want to eat" + " " + parameter);


yourfunction_name_without_space ( "Sushi"); [ I called the function outside with a input Sushi which will replace the parameter]


You are calling food which doesn't exist

You syntax should look like this:

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


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