Introduction to Functions in JS lesson 12


#1


https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661#


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!";
}
};
sleepCheck(10);


#2

Hi,

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: http://www.w3schools.com/js/js_if_else.asp

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

#3

thank you so much

..


#5

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