My code is returning something strange


#1


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


Oops, try again. It looks like your function doesn't return false when hungry is false.


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


#2

your if condtion:

if (true && true)

why use true and true?


#3

because I thought that was what I was supposed to do


#4

but true and true are always true, they are not depended on the values of food an hungry.


#5

oh okay I tried to fix it by adding the foodHere and hungry variables but I messed it up.


#6

can i see an updated version of your code? You need to check if foodHere and hungry are true


#7

yes

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


#8

this code works fine?


#9

I just tried it, and It worked. Thanks, all I did was the comparing thing from my other topic.


#10