Is this the corrected outcome to this exercise?


#1



Functions & if / else
https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661#


I have passed this test but it has printed all three. Is that the desired answer for this task or was it only meant to get one of them? I guess I never actually specified one...
Can you guys just confirm this is correct and not a bug.

Thanks in advance!


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!";
}
};


console.log (sleepCheck(10));
console.log (sleepCheck(8));
console.log (sleepCheck(5));


#2

I now see why... I asked for 3 at the bottom. Need to go to sleep before I think too much about this.


#3

Well, you did specify to log all the three at the bottom of your code:

console.log (sleepCheck(10));
console.log (sleepCheck(8));
console.log (sleepCheck(5));

That's why it got printed as well :slight_smile: