Error in Functions & if/else


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661#


Oops, try again. There was a problem with your syntax.
SyntaxError: Unexpected token :


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


#2

Hi this line

return "Get some more shut eye!":

you ahve the : at the end

And

here

var sleepCheck = function(numHours)

you wrote sleepCheck instead of SleepCheck with the uppercase S


#3

Hey @youngq,

so far, @wizmarco is right.

But at the end, instead of an uppercase S you should write those function-calls (sleepCheck();) with a lowercase s. (Vice versa :stuck_out_tongue:)

So your code should be something like:

// Write your function below. 
// Don't forget to call your function!
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!";
    }
}

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

Greez.


#4

Thanks, it works now.


#5

Thanks, it works now!