11. And


#1

I've been stuck on 11. And for a few days but every time I submit my code it says Syntax Error: Unexpected Token {... Here's my code, can anyone tell me what I'm doing wrong?

var hungry = true
var foodHere = true

var eat = function {
if (hungry && foodHere = true)
{
return true
}
else
{
return false
}
}


#2

you should write like this:if(hungry&&foodHere==true) ,one equal mark means assignment,two or three equal marks means judging whever their typement or value is equal.
And you should add a parentheses after the word of funtion,as it is var eat=function(){ }


#3

I's not the = sign that's messing it up, its a {. I have the if/else statement inside my function.


#4

haha i was stuck because was using console.log instead of return and found your topic...
here is the working code I wrote:
var hungry = true;
var foodHere = true;
var eat = function() {
if (hungry && foodHere) {return true;}
else if (hungry || foodHere) {return false;}
else {return false;}}

which means if both are true will return true, if one is true returns false and both false returns false.