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


#1


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?


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

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


#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: