SyntaxError: Unexpected token else


#1

I don't know what is wrong with my syntax and I don't understand the red lettering on my screen. Please help me!

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);
if(numHours>=10) {
return "You're getting plenty of sleep! Maybe even too much!";
};
else {
return "Get some more shut eye!";
};
sleepCheck(5);
if(numHours>=5) {
return "You're getting plenty of sleep! Maybe even too much!";
};
else {
return "Get some more shut eye!";
};
sleepCheck(8);
if(numHours>=8) {
return "You're getting plenty of sleep! Maybe even too much!";
};
else {
return "Get some more shut eye!";
};


#2

Hi you could do it like that

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!";
};
};

And then call the function sleepCheck with the other Hours like that

sleepCheck(10)
sleepCheck(5)
sleepCheck(8)