Confused on "Functions & if / else". Introduction to Functions in JS


Introduction to Functions in JS
Functions & if / else

Hi I am confused on the subect "Functions & if / else" on "Introduction to Functions in JS"

Updated Error:

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.

Updated Code:

// Write your function below. 
// Don't forget to call your function!
var sleepCheck = function( numHours ) {
        if ( sleepCheck >= 10 ) {
                return "You're getting plenty of sleep! Maybe even too much!";
        else ( sleepCheck < 10 ); {
                return "Get some more shut eye!";

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

Updated Output:

"Get some more shut eye!"


while this post is up, I will be trying to figure it out.

Help on "Functions & if / else"

You didn't use the parameter named numHours in your just took it as parameter. you are checking
if ( sleepCheck >= 10 )

what's sleepCheck?
and here

else ( sleepCheck < 10 );

else doesn't allow to have a don't need it too.


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