One output but 3 function calls


#1

It works but it says "You're getting plenty of sleep! Maybe even too much!" when I called the function three times. There is only one result and at the bottom I did sleepCheck(5);. 5 is less than 8. Plz help.

// Write your function below. 
// Don't forget to call your function!
var sleepCheck = function(numHours) {
    if(numHours >= 8) {
         return "You're getting plenty of sleep! Maybe even too much!";
    } else {
        return "Get some more shut eye!";
    }
};

sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

12. Functions & if / else issue
12. Functions if/else problems
#2

I moved your question to a separate topic because it has a different question. From what I can see you're not using any output function like console.log. So what you see is the default console output which echoes the last value that occurs in the code which is in your case the value of this function call

sleepCheck(8);

which has a value of the returned value:

"You're getting plenty of sleep! Maybe even too much!";

So in order to see the other two as well you need to wrap them all in console.log statements:

console.log(sleepCheck(10));

and so on. Hope this makes it clearer.


#3

Thanks! It let me move on.