12. It looks like sleepCheck() isn't returning "You're getting plenty of sleep!


#1

Hello,

I am also getting the same error message - Oops, try again. It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10. Check your if / else syntax and whether you're using the correct comparison operator.

The correct output display in the console log.

My code is -

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(5));
console.log(sleepCheck(8));

Apologies for jumping on a thread, didn't want to start a new one for the same issue.

Thanks,

George


12. Functions and if/else question
#2

Is something missing after "too much"?


#3
  1. Within your if/else statement, there is no need for >=. Just use the greater than symbol.(>)
  2. Towards the end of your code, you only need to call sleepCheck one time.
    A. When giving o function its value, there is no need to log it to the console.
    The code should look similar to this:
    sleepCheck(10);
    Hope my response helps!

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.