Intro to functions js


#1

var foodDemnd = function ("food") {
console.log("I want to eat" + " " + food);
};
foodDemand("chocloate");
what am i doing wrong???????


#2

Hi,

Take a look at the first line. You are using a string within the parenthesis. It's not a variable now. Make sure to remove those and try again - also forgot to add an "a" in foodDemnd in line 1, hope that helps! :smile:


#5

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

this is what i came out with and it said that it did not print anything to the console


#6

Hi,

You should call your function outside the brackets, like this:

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

foodDemand("chocolate");

Your function already logs some text to the console, so it is not necessary to ask the console to log again


#7

A post was split to a new topic: sleepCheck Function help!