Functions & if / else - SleepCheck help!


Hi, I don't know what's wrong with my code. It says "Oops, try again. There was a problem with your syntax."

Line 7 shows an error message saying: "Expected and identifier and instead saw 'else'. Missing ";" before statement" but I don't know how to fix this issue.

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


Just looking at the code, the semicolon after your if statement conditional should be a curly brace, though otherwise your code is identical to my own and it doesn't seem to be working. Anyway, hope this brings you a step closer to the solution.

quick edit, you also need to close the curly brace for the block of function code.


Exactly right.
The semi-colon after the 'if' statement is stopping everything
Curly brace there and one at the end of the function and the code looks good!


I see! Thanks very much. It's working now :slight_smile:


Glad you got it working, discovered my own wasn't passing as has a spelling error in the string!


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