Functions & if/else


#1



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


I don't really know what I'm doing wrong but it keeps saying "SyntaxError: Unexpected token else"...some help would be greatly appreciated thx ;D


// 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(5);
sleepCheck(8);


#2

if is missing its closing curly bracket (})


#3

P.S. Is there any way to change my username "terraplayer"...
:3


#4

@teraplayer78308,
You forgot to use a closing-curly-bracket-}
to close the IF code-block
like

    if (numHours >= 8) {
        return "You're getting plenty of sleep! Maybe even too much!";
    }

#5

Did you resolved the issue? You can try it on the main site, and then in account settings, you can change your username, if it is still available.


#6

Ahaha yea thx yall gr8 help in both aspects :smiley: