11.And——why the code is not right?


#1


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


Oops, try again. It looks like your function doesn't return true when hungry and foodHere are both true.


var hungry = true;
var foodHere = true;

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


#2

Instruction:

The function eat should take no input and hungry and foodHere should both be globals.

so you don't need any parameter for the function


#3

Got it. Thanks for you help!


#4

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