Functions and if/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!"};

It says "Syntax Error!". I can't find out the error. please help!


Your function is missing { }

After (numHours) you need to have your opening curly bracket and you need to close it after your else statement
When closing your if statement remove the semi colon from after the curly bracket.


Oh it works!!! Thank you very much. But, I don't understand why we need to put curly bracket before if statement. Can you please explain to me?


You mean the function? Why you need to add curly brackets to the function?

As whatever is in the curly brackets is what in the function, the first line declares the 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!";

pls someone should help me figure out the syntax error. i cant see it myself.


This semi colon needs to go