Functions and if/else - chapter 12


#1



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


Oops, try again. It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10. Check your if / else syntax and whether you're using the correct comparison operator.


var sleepCheck = function (numHours) {
    if (numHours >= 8)

    { return "You're getting plenty of sleep!  Maybe even to much!"; }
    
    else
    { return "Get some more shut eye!"; }

};
sleepCheck (10);
sleepCheck (5);
sleepCheck (8);


#2

Does anyone know what the ■■■■ is wrong with my code


#3

Try removing one space after the exclamation mark since the error points on the return statement.

return "You're getting plenty of sleep! Maybe even too much!";

#4

did not work any other ideas


#5

Uhmmm... Okay, copy and paste this whole stuff as edited below:

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!";
       }
};
// calling your function!
console.log(sleepCheck(10));
console.log(sleepCheck(5));
console.log(sleepCheck(8));

#6

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(5);
sleepCheck(8);
sleepCheck(10);


#7

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