Problem with function


I have the following issue. My code is running, however, I still get the error from the system. Please advice here.

My code is:

var sleepCheck = function (numHours) {
if (numHours >= 8) {
return (“You’re getting plenty of sleep! Maybe even too much!”);
else {
console.log(“Get some more shut eye!”);

The result is:
“You’re getting plenty of sleep! Maybe even too much!”

Beside that, I still got the same 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.

I tried with different combination with return and console.log, doesn’t help.


Are you asked to return this? Or to log it?

console.log(“You’re getting plenty of sleep! Maybe even too much!”);


I"m ask to return it. I’ve tried all possible option with return and console.log. It still doesn’t run. I wonder what is the mistake or it’s a bug in the learning software.


We will need a link to the exercise to investigate further. Please post one. Thanks.


Thank you Sir!


The expectation of this exercise is return values for 10, 8 and 5 hours of sleep. Both branches of your conditional need to return a string, which above looks like you have copied them correctly from the instructions, also important. They must be identical.

The thing we do not need is parentheses around the return value. Drop parens on returns unless you are grouping in an expression. The value is already in quotes; that is explicit enough for the return to be a string object.


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