11/14 my code's not right


#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("true");
}
else {
console.log("false");
}

the error I'm getting says "SyntaxError: Unexpected end of input"

the only thing that I would guess is wrong is that I didn't put any parameter for the function eat, its just () blank.
but the instructions say that the eat function should have no input, so I thought that means that you should leave it blank?


#2

If you don't need a parameter, you don't need a parameter :smile:
Unexpected end of input often implies that something is not closed in your case I'd suppose its a missing } for the function. Also I guess the required output is true/false (boolean) not "true"/"false" (string), is it?


#3

yea it wanted
return true;
}else{ return false
}

still don't quite get the difference between console.log and return, but in this case it makes sense because the computer sees "true" differently from how it sees true, the boolean


#4

Return and console.log are fundamentally different. console.log is a function that lets you output stuff to the console. Return on the other hand is a keyword for function that manages the return from the function scope back to the calling scope and let's you carry values with it. There is a console feature which echoes the last value unless it is undefined and if a function call using return is the last statement this might lead to seeing the returned value on screen. But this is rather a side effect than an intended behaviour. So for a reliable output to the console use console.log and for an output for your function to the calling scope use return.