Logical operators exercise


#1

I understand the exercise. My question is, isn't return supposed to print out the value in the console? if yes, it does not print out in the console but I am still being passed for the lesson.
Thanks

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

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


#2

No, return does not have anything to do with printing. We have to log the return value:

console.log(eat());    // true

#3

I'm not sure if I'm missing something. I underestand you saying return doesn't have anything to do with printing. But in More on Control Flow in JS section 13, for the not logical operation, the exercise is this and it prints out the return of true in the console. Does calling the function cause the return value to print out in the console?

// Declare your variables here!

var programming = false;

var happy = function() {
// Add your if/else statement here!
if(!programming){
return true;
} else {
return false;
}
};

happy();


#4

What you are seeing is normal console behavior. When the code finishes executing, the console will 'dump' what is in the buffer. To experiment, add this line after the happy() call:

    console.log("bye");

Now you won't see the output true.