Working with Javascript and problems


#1

I can't seem to get this right,

Oops, try again. It looks like you didn't put quotes around the food you gave foodDemand!
var functionName = function(foodDemand){
console.log("I want to eat" + " " + food);
};
functionName("crackers")

ReferenceError: food is not defined

how do I define food? I thought putting it in the parentheses and using the foodDemand variable would cause food to be defined with whatever I put in the parentheses after functionName on the last line.


#2

Hello @pyninja64685,

your code:

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

your supposed to declare a var called foodDemand, not functionName
your parameter is NOT supposed to be foodDemand, put food instead
lastly you should call your foodDemand function and place a "string inside"

your code should look something like this:

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

#3

Thank you so much, I thought I had tried that and I had...only forgetting to call food demand I was still calling functionName...I'm working on it, getting there. Thanks again.


#4

@pyninja64685 glad to help :smile: