11/14 Oops, try again. Did you declare a variable called hungry?


#1

var hungry = true;
var foodHere = true;

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

I'm also getting "ReferenceError: Invalid left-hand side in assignment" in the console.

I set var hungry in the first line!!
Thanks in advance.


#2

"=" isn't a comparator. "===" means equal to. Change "=" to "===".


#3

The problem with the invalid left-hand side assignment is here:

hungry && foodHere = true

as && has a higher priority as = you first compute the value of hungry && foodHere which leads you too

true = true

an as you can only reassign variables but not values you get an error for trying to reassign true even if it is with its own value. What you need to fix this is already explained by @ragezapper


#4

you set the IF inside the FUNCTION "eat" and did not call the function at the end.

// 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;
}
};
eat ()