Cannot figure out what is wrong with my syntax


#1



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");
};


#2

Take out the = and space


#3

Just did. Still shows the syntax error.


#4

val also has to go..


#5

Removed that as well.

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


#6

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]


#7

You are calling food which doesn't exist

You syntax should look like this:

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

#8

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