Does anyone know where I went wrong?


#1

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


#2

Alright a couple things.

console.log("I want to eat " + food); //My code

instead of

console.log("I want to eat" + " " + food); //Your code

There's nothing wrong with your code, it's just cleaner when it looks like mine.

The only problem you have that causes your code to not work is this line.

foodDemand(console.log("apple"));
                    ^

Two things.

1) When you're calling the "foodDemand" function, make sure you aren't trying to call the function from inside itself. That's kind of like saying "I'm going to eat myself" It's just not going to work.

2) When you call foodDemand you will be passing it the parameter "apple" like so:

foodDemand("apple");

When you pass the function that parameter it'll run the code and take "apple" and replace (food) with "apple"

Example.

var foodDemand = function("apple"){
console.log("apple");`
}

That is what the function will see. But all you'll see is this:

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

#3

I hope this helps!

Otherwise if you have any further questions please don't hesitate to send me a message and I'll see what I can do!


#4

Thank you! I was super confused there for a second but I get now. Thanks again!