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


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




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


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


@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.


Thanks for the timely response!


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