12 if/else is not working


var sleepCheck= function(numHours) {

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




I'm not sure what your problem is. I just ran the code and it works fine. can you send a link to the assignment? it might have to do with the instructions.


if the error code says something like "You didn't return 'get some more sleep'. chances are that you just need to copy and paste the text from the instructions. if its not that then ill need to see the assignment to tell you more.


I'm having the exact same issue. The error I'm getting is:

"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."


SleepCheck is a function name, numHours is the parameter for the function.
so, if you want to use parameter inside the function (inside the curly bracket), you have to take the parameter which is numHours in your exercise.
var sleepCheck = function (numHours)
if (numHours >= 8) {

but when you want to call the function, call the function name which is sleepCheck.
ex. sleepCheck();


your code looks fine. whats error are you getting?


that should be if(numHours >= 8)


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