My code looks correct but keep gettin error


#1

My code looks identical to all the answers I've seen but it still doesn't pass me.

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

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.


#2

The answer is in the error message:

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!";
    }
};

#3

Sorry guys I figured out I typed "gettin" instead of "getting". Shouldn't it return three results though. I only get the first result returned not the other two but it still passed me.


#6

Your code (once corrected) is all that is expected. The output you are seeing is the response from the command line interpreter (since we are using the console). To view the actual output, log each call expression:

console.log(sleepCheck(10));
console.log(sleepCheck(5));
console.log(sleepCheck(8));

#7

Ahhhhh....that makes perfect sense haha. So what I was actually seeing was the last result after it ran through all three. I just tested it. I get it now. Thanks man.


#8