11. And



Help guys! What am I doing wrong?

var hungry = true
var foodHere = true

var eat = function() {
    if(hungry && foodHere){
    else {



Create two variables, hungry and foodHere, and set them both equal to true. Inside the eat function, create an if statement that returns true only if both hungry and foodHere are true, and false otherwise. The function eat should take no input and hungry and foodHere should both be globals.

What are you doing:

console.log(true); // Oops!


OK, what if I wanted it to print true?


var result = // call function;
console.log(result); // yay!


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

what's wrong with this?


Missing a starting brace for the if block.


same problem here for me.


You have to return true/false instead of printing strings.


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