How does a function work?


#1

1.Declare your function and call it foodDemand.
2.You can call the parameter anything you like. But we'll call it food because that is the thing that is going to change each time we call the function.
3.Your reusable block of code follow this. Surround it with the right brackets. The code you want to repeat is: console.log("I want to eat" + " " + food);
4.Call the function and put in a specific food you want!

ans:

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

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

but still it is showing "ReferenceError: Rice is not defined"


#2

.Declare your function:

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

Call the function:

foodDemand(Rice); //it'll show "ReferenceError: Rice is not defined"

Rice should be into " " that is foodDemand("Rice")

check it
https://discuss.codecademy.com/t/i-do-not-understand-how-to-call-a-function-what-am-i-doing-wrong/37701/7?u=rcodeman


#3

oops try again,
it is still not working, please I need help
https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/4?curriculum_id=506324b3a7dffd00020bf661#


#4

can you please give me your updated full code?


#5

Actually i just copy your code.i didn't notice that.
here

var foodDemand=function (food){  
    console.log("I want to eat"+" "+"food."); //here  write food without quotes and remove . too after food
    
};

so it should be
console.log("I want to eat"+" "+ food.);


#6

thanks, I have gotten it.


#7

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