0

I am learning JavaScript on codeacademy and I came upon an error as I was doing a lesson and I could not figure out how to fix it. The error was

SyntaxError: Unexpected token else.

Here is my code:

sleepCheck = function (numHours) {
    if (sleepCheck >= 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) ;

This was supposed to be a sleep checker. I was learning about functions and the return keyword.

j08691
  • 204,283
  • 31
  • 260
  • 272

1 Answers1

0

The issue is the ';' before the else and after the '}'

  • 2
    We tend to avoid formal answers to questions where the answer is due to a typo (we have close reasons for that). Questions like these are unlikely to help anyone in the future and are low quality. You can also see that the answer was given several times over in the comments section. – j08691 Dec 31 '14 at 20:26