11/14 Did you declare a variable called hungry?


#1

I don't know what's wrong with this


#2

if (foodHere=true&&hungry=true){

should read,

if (foodHere === true && hungry === true){

or more simply,

if (foodHere && hungry){

#3

but why i can declare variable by using =,but i can't use =in the "if"conditoin?


#4

Because = is only for assignment, not comparison. For that we need ===, or some truthy expression. Since foodHere and hungry are both Boolean, they are valid expressions.


#5

i got that~thank you for your help