My code wont work


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;   


your code..

if/else syntax

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

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


if (hungry && foodHere === true)

This will be suffice..

if (hungry && foodHere )


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.


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