Some explanation about And


#1

i did not call the function by writing eat() at last line, but it works , how ? can anybody explain me plz .
// Declare your variables here!
var hungry = true;
var foodHere = true;

var eat = function() {
// Add your if/else statement here!
if (hungry && foodHere) {
return true
}
else {
return false
}

};


#2

the exercise likely calls the function to validate your code is correct, what is it you don't understand?


#3

to call the funcntion , i had to write 'eat()' at end line of the code , i did not do that , but the code worked . how ?


#4

yes, a function only executes when called.

codecademy needs to verify your code, in order to do so, the function is called behind the scenes


#5

i want to say that i did not write 'eat()' to execute the function , but it executed , how ? would u tell in other way.


#6

because the exercise calls the function behind the scenes? given the exercise has to validate if your function works correctly executing the function is required, so the exercise does that for you behind the scenes


#7

codeacademy just verify my code , and it call the function from behind the scenes. but in practical project i must hve to write eat() at finishing line , am i right ?


#8

if you want the function to execute, yes.


#9

thank u so much...........................................


#10