Introduction to Functions in JS lesson 12


Oops, try again. There was a problem with your syntax.

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



remove (numHours < 8) in your else statement!

There is no condition needed, because it is else not else if

Here is some information how to use if/else statement:

In JavaScript we have the following conditional statements:

  • Use if to specify a block of code to be executed, if a specified condition is true
  • Use else to specify a block of code to be executed, if the same condition is false
  • Use else if to specify a new condition to test, if the first condition is false
  • Use switch to specify many alternative blocks of code to be executed


thank you so much



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