Functions and if/else lesson is bugged


Currently stuck on this exercise. I have confirmed with a friend who knows Javascript that my code does exactly what it is supposed to. I've attempted to complete this lesson with this exact code in both Chrome and Firefox. In both browsers, it returns the error message, "Oops, try again. It looks like your function doesn't return "Get some more shut eye!" when numHours is 5. Check your if / else syntax and whether you're using the correct comparison operator." I have come to the conclusion that this lesson is bugged. Could an admin please pass me through the lesson? Thank you.

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


I think you not nessacary need to put the 'console.log' because your code at above already put 'return'

just put directly sleepCheck(5); or any number you wish in the bracket


opps sorry..
I just checked and actually the console.log didn't affect anything..
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!";


It still worked for me.. sorry


yeah, the console.log is necessary because "return" just stores the value returned by the function in the "variable" that is the function. If I weren't to console.log it, it would only return the result of the last function due to a handy console function that echoes the last unaccounted variable.


u can try copy paste my code to your page..
because my code worked for me..
or u try to refresh the page :slight_smile:


I've tried refreshing the page already. Your code is literally identical to mine except for formatting. I appreciate your advice, but what I really need is to skip the lesson until it's fixed.


I think I found your error already..
you should use "Get some more shut eye!"
instead of
"Get some more shut-eye!"

the "-" effect


Thanks. That fixed it. It's kind of silly that I can't have dashes in my strings, but whatever.


yea you need to follow the instruction completely.
sometimes it get me too..