Introducing to Functions in JS 12/13


#1

Hey guys! Is it okay that result screen returns only this:

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

It should return 3 messages.
Here's my code:

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);

It should return:

"You're getting plenty of sleep! Maybe even too much!"
"Get some more shut eye!"
"You're getting plenty of sleep! Maybe even too much!"


#2

Yes this is ok, if you think about it you're not printing anything yourself but just use the console feature that echos the last value if it is not undefined. So if you want to see all outputs you need to e.g. wrap them in console.logs.


#3

Okay. Thanks! :wink: