Lesson 12 Functions $ if/else


#1

I can't figure out what is wrong with this code. I've looked through all the other help topics. It is saying there is a problem with my syntax. Could someone please help?!

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

@molliesheridan,
A semi-colon-; is an End-of-Statement indicator for the Javacript Interpreter.

Thus if you write your code like

if(numHours>=8);

the IF code-block

    {return "You're getting plenty of sleep!";"Maybe even too much!";
    }

is not seen as to be part of the IF ELSE statement
and the Javascript Interpreter is not expecting an ELSE ....