12 Functions, IF & ELSE


#1


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


What is wrong with my code? 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 (sleepCheck => 8){
        console.log ("You're getting plenty of sleep! Maybe even too much!")
    }
    else {
        console.log ("Get some more shut eye!")
    }
}
sleepCheck(10);


#2

I changed the console.log's to return statments


#3

Why is sleepCheck in your condition?

Step 2 of the instructions reads:

Inside the function, write an if
statement where if the number
of hours of sleep is greater than 
or equal to 8, the computer will 
return "You're getting plenty of sleep! 
Maybe even too much!";.

Make the necessary correction to your if condition :slight_smile:


#4

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