If else in function


#1

Hi I am struggling with this code:

var sleepCheck = function(numHours)
{
    
   
    if (numHours <= 8){
        console.log("You're getting plenty of sleep! Maybe even too much!");
}else{
    console.log("Get some more shut eye!");
    }
}
sleepCheck(6);

Wat is wrong ? It shows both messages. Or the same double when I raise numHours to 8. Thx :slightly_smiling:


#2

Instead of having the function log the message like this:

console.log("You're getting plenty of sleep! Maybe even too much!");

the exercise is expecting you to have the function return the message, like this:

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

Also, check the comparison operator that you are using. It isn't the one that the exercise is expecting.