11/14 - Could not get this, please help!


#1

// Declare your variables here!
var hungry = true;
var foodHere = true;

var eat = function() {
// Add your if/else statement here!
if(hungry && foodHere){
console.log("Amen!");
}
else if(!(hungry || foodHere)){
console.log("Twosome!");
}
else{
console.log("Hmm");
}
};


#2

This my code for 11/14 in "More on Control Flow in JS":

var hungry = true;
var foodHere = true;

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

I do not know why you have added ||, nor an "else if", for it was not needed, and it may not work if you don't follow the directions, which happens sometimes.

Anyways, what I'm saying is that you do not have to add these extra things in your code, and it may not work because of that.

Hope it helped!:smile:


#3

I should not have added unnecessary lines, your guidance helped, Thank you.


#4

I made same mistake :D:D


#5

this works:

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

else(!(hungry || foodHere))
{ return false;
}
};


#6

Hi,

Just add this code.

eat();

I was finding same issue, later added above code which worked for me.