Functions & if / else (I think it works but Codecademy doesn't)


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.

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


This should be in the Introduction to Functions in JS category.


You have an extra spaces try removing it this lesson is expects you to have exactly the same text


CodeCademy is very picky about the quotes. Make sure you copy it exactly as the lesson asks


I'm having a problem on this one too.

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

sleepCheck (10);
sleepCheck (5);
sleepCheck (8);

I put in: else if (numHours < 8) but then it would only check the first sleepCheck.

That said, I dont think you need to use console.log at all in this one



If you're having a problem, please post this in a new topic with your question + error message + code. Just a question of keeping the forum clean.


Don't log this to the console! You should call it. To call a function remember this syntax:

functionName(optional parameters);


This exercise was driving me nuts and I just figured it out. My program was generating all three responses, but Codecademy wouldn't let me pass the exercise. After a lot of trial and error, this is it:

Codecademy will only accept your code for this exercise if you only type 1 blank space after "sleep!" and before "Maybe." You cannot enter 2 spaces between the exclamation point and the "Maybe" because if you do, Codecademy won't accept it. It must be ONLY one blank space between exclamation point and the word "Maybe." Otherwise, you will get stuck.

This is a really lame bug to have in the program since all people are taught to put 2 spaces after punctuation!


Thanks a lot !!!
This seriously worked!