Lesson 12 - Functions & if/else


#1


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!";
    }
};
    sleepCheck(10);
    sleepCheck(5);
    sleepCheck(8);


#2

Just a minor typo. "plenty"


#3

Oh dear, what a simple mistake. Thank you!


#4

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.


#6

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


#8

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