Why is it saying else is an unexpected token?



I am getting a syntax error saying that there is an: unexpected token else.

    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!");


There is a semicolon before your else statement. Semicolon use is tricky. Here's a link that may come in handy on that topic:



Thank you, it works now, and the guide really helps me understand semicolons better.


Yeah, it'd be nice if they went over stuff like that before lessons, glad it helped :slight_smile:


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