I got the "food function" right, but I don't understand how it works


Why do I get the same result when I change the parameter value when calling the function?

So I got it right and everything, but if I call the function but change the parameter value to "Pizza", it still comes out as "I want to eat food". I don't understand what the parameters actually do and what changes when I change them?


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


when calling the function:


you pass an argument, which is then stored in the function parameter:

var foodDemand = function(Pizza)

so then Pizza is your function parameter, which will hold the argument passes, so if you want to display the argument, use the function parameter:

console.log("I want to eat "+ Pizza);

you can see the parameter as a variable, so you don't have to use " around the function parameter.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.