3.4 Functions & if/else says there is syntax error on if/else statement


#1

What is wrong here? When I submit the code it will say "Get some more shut eye!;" on the console, but the "You're getting plenty of sleep..." isn't coming up and it's saying there is a syntax error in the if/else statement. I copy and pasted an answer to another thread and it said it was correct, but I couldn't find a single difference.

var sleepCheck=function(numHours) {
if (sleepCheck>=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

if (sleepCheck>=8) {

you compare the function name to a number so you'll most likely always pick the else case. Also wrap your function calls in console.logs as you otherwise just see the last of them. (console feature printing the last value of your code, is not accepted if console.log was asked for).


#3

Thanks, that helps a lot.