Lesson 12 - Functions & if/else


I'm getting the error "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."

However, the console is displaying "You're getting plenty of sleep! Maybe even too much!"

Where did I go wrong?

var sleepCheck = function(numHours) {
    if (numHours>=8) {
        return "You're getting plently of sleep! Maybe even too much!";
    else {
        return "Get some more shut eye!";


Just a minor typo. "plenty"


Oh dear, what a simple mistake. Thank you!


It happens to the best. That's why we proofread, again and again. One way to fool our brain (which is usually about four words ahead of our eyes) is to scan from the end, going backwards. Our brain is less likely to trick us since we are going against the normal reading grain.


A post was split to a new topic: I have the right code but still getting the same error


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