Introduction to Functions in JS | 12. Introductions & if/else


#1

Can anyone help me with this:

var sleepCheck = function(numHours) {
if (numHours >= 8){
return "You're getting plenty of sleep! Maybe even too much!";
} else (numHours < 8) {
return "Get some more shut eye!";
}

sleepCheck(10);

sleepCheck(5);

sleepCheck(8);

It's displaying "Oops, try again. There was a problem with your syntax."


#2

must be just } else {
you also forget to close the function


#3

@konaesan is right.

And you need to close body of your function with };. Please note that the last } is closing the else block, not the function body.


#4

Thanks for the timely response!


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.