Functions


#1

Wow, I'm not understanding anything about that. Let's see Why:

SyntaxError: Unexpected token

Oops, try again. There was a problem with your syntax

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

What's the correct response ?


#2

You are supposed to open brackets after declaring your function.

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


#3

Well, After I openned brackets, came out:

Oops, try again. You did not call foodDemand!

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


#4

I think it's:

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

Or whatever food you want to add. You added the word function when you tried to declare the variable, thus changing your variable to functionfoodDemand instead of foodDemand.


#5

thank very much, man !!!


#6

I didn't finished yet. Let' break it up another Function ?

SyntaxError: Unexpected token var

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

// Badly written function with syntax errors!

greeting var func{name}(console.log(name)))}
var greetingfunction = function(greeting) {
console.log("Hello, World!");
};