AND exercise


Where is the error in this code?

var hungry = true
var foodHere = true

var eat = function() {

if (hungry && foodHere === true); {
return true;
} else {
return false;


Hi this part remove the ; after the if condition

if (hungry && foodHere === true); <==this one


Just did it and it works. Thanks a lot! But I have no clue why this makes a difference? What does the ; do then which makes it return an error?


you could read about it in this topic..


@robertkooyman Also, considering you understand if (hungry) I think you could go with foodHere in place of foodHere === true. (disclaimer: I'm not as familiar with && and || as @wizmarco is; hopefully he'll weigh in if I'm wrong :wink:)


Hi yes @msfrisby he could... but the Lesson want him to use the comparator &&..


Thanks, @wizmarco! :smiley:

I did mean I wasn't totally sure if if (hungry && foodHere) was valid.
But dang! Why do I barely remember this lesson?? Maybe I need to take it again :computer::pencil2: