12. Functions - SyntaxError: Unexpected token else


#1

could someone please help me out with where i went wrong with the syntax

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


#2

There is never a semi-colon before else, otherwise it is treated as a new statement, and statements do not begin with else.


#3

understood, thanks for the response!


#4

2 posts were split to a new topic: Not working please help


#5