Functions and if/else statement


#1

Gives me "SyntaxError: Unexpected Token" But I am not sure why.

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!";
}
};
console.log(sleepCheck(10));
console.log(sleepCheck(5));
console.log(sleepCheck(3));


#2

I've been having the same problem. The coding I've been using is the exact same and I get the same error message. I am very confused as to why..


#3

The same exact thing has been happening to me, too. I finally decided to just move onto the next exercise, but am still trying to figure it out. Maybe it's a glitch?


#4

I actually looked over the coding and found out the right way to do it. I got through this by taking out the semi colon in most of the coding.

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)


#5

var sleepCheck=function(numHours); //<-- no semicolon here


#6

The answer has to be twice
You're getting plenty of sleep! Maybe even too much! (for 10 hrs and 8 Hrs)
Get some more shut eye! (for 5 hrs)
Something is wrong because the tutorial aprove my answer and yours.