11. And, need help please


#1
  1. And, need help please

The console display always shows this: It looks like your function does not return false When hungry is false. and when I put only: if (hungry && foodHere) {return true;
}; gives error saying SyntaxError: 'return' statement outside of function.

https://www.codecademy.com/pt/courses/javascript-beginner-en-qDwp0/2/2?curriculum_id=506324b3a7dffd00020bf661


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


#2

excuse me updated the code, but it is still wrong ...

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


#3

My code is this:

// 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;  
  }
};

#4

guy it works, but shows nothing on the console display, but thanks


#5

ah, I understood just put the end of the code: eat () ;. there will appear on the console "true". hehe