Functions and if/else -- what is wrong with my code


#1

Getting syntax error: expecting " { "

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(7);


#2

Remember that this whole if statement block is apart of the sleepCheck function. That said you need a { at the end of the first line (Remove the ';' ). And then you need a '};' before you call your function with sleepCheck(7);

Your code should look like this:

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(7);

#3

Thanks. That worked!