11. Control flow


Good day Codecademy forrum, how do I declare that hungry is false is I have already declared the variable to be true?

The feedback is "It looks like your function doesn't return false when hungry is false."

This is my code:

var hungry = true
var foodHere = true

var eat = function() {
if(hungry && foodHere) {
console.log("I am hungry but food is here!")
} else if (hungry || foodHere)
console.log(" I am hungry but no food is here")


Should my answer be else hungry = false?


Hi you should add a else statement


I believe the actual exercise is asking you not to console.log, but to use the return command to return the variable hungry as TRUE when both variables are true and write an ELSE statement that returns FALSE on all other situations

An example of this is:

// Declare your variables here!
var hungry = true;
var foodHere = true;

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

return false;


This loop will return TRUE when both hungry and foodHere are true and ELSE it will return false.