Why do we have to write 'return' not 'console.log'?


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

So this code is displaying an error(I know why). The purpose of this question is as to why we cannot use console.log in this situation? Why do we have to use return?
<In what way does your code behave incorrectly? Include ALL error messages.>

```

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

var eat = function() {
if(hungry && foodHere){
console.log(“true”);
}
else {
console.log(“false”);
}
};

<do not remove the three backticks above>

#2

Because the exercise wants you to use return, if this where you own code, you where free to choose between console.log and return


#3

Oh, OK, thanks a lot!:wink: