My code wont work


#1


More on Control Flow in JS - 11. And


SyntaxError: Unexpected token else


// Declare your variables here!

var hungry = true;
var foodHere = true;

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


#2

your code..

if/else syntax

if (condition) {
        //your code   
  }
  else {
      // your code   
  }

Notice there is no semicolon after if statement's ending curly bracket.

also

if (hungry && foodHere === true)

This will be suffice..

if (hungry && foodHere )


#3

Thanks it worked! and yea that's what I was thinking but i saw other peoples when I was trying to find why mine didn't work and I just left it.


#4

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