Logical operator AND


#1

var hungry = (true);
var foodHere = (true);


var eat = function() {
    if (hungry && foodHere) {
        console.log("Hungry, food here")
    } else {
        console.log("Not hungry, no food here")
    }
};

what's wrong with this code, I keep getting this message:
Oops, try again. It looks like your function doesn't return false when hungry is false.


#2

The exercise is asking you to return true or return false depending on the situation. You have not specified any return values but have instead logged some messages to the console.

Do you see how you can fix that now?


#3

thank you, i've got it know :grinning:


#4

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