11. 'And' problem - I just don't get it!


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-qDwp0/2/2?curriculum_id=506324b3a7dffd00020bf661


So, what is wrong in the code here?

var hungry = true
var foodHere = true

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

};

eat()

it says:
SyntaxError: missing ( before condition


var hungry = true
var foodHere = true

var eat = function()

{
  if (hungry && foodHere) {return true;}
  else if {return false};
  
};

eat()


#2

else if requires you to use a condition, i would else instead, since you don't need a condition


#3

nothing wrong in your code...
I assert that...but.. you can refer my code
//by google trans....i cant's speak English..so i used Google trans....if some think wrong . Please sympathize


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

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


#4

ah ha..i see a error..this is
"else if"......
you can use it like that..
if (condition 1) {do some think;}
else if (condition 2) {do some think; }
else{
some think else;
};
////hi... is that true..


#5

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