Functions Question 13


#1

Getting error of undefined sleepCheck() however program responded as required

// Write your function below.
// Don't forget to call your function!
var sleepCheck = function(numHours)
{
sleepCheck=numHours
return numHours;
}
sleepCheck(10);

if (sleepCheck >= 8)
{
console.log("You're getting plenty of sleep! Maybe even too much!");
}
else
{
console.log( "Get some more shut eye!");
}


#2

The instructions want you to put the if/else block in the function and also you mus get rid of this line it is unused

sleepCheck=numHours

Her try this

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

or

Check out this demo