Stuck on Sleep Check JavaScript


#1

var sleepcheck = function(numHours) {
if (numHours >= 3) {
return ("You're getting plenty of sleep! Maybe even too much!");
} else {
return ("Get some more shut eye!");
}
};

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

It says "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."

And I have no idea why it isn't working


#2

A few syntax errors messing up the whole thing. For your returns they don't need parentheses. Rather, it should be:
return "You're getting plenty of sleep! Maybe even too much!";

As for the calling of sleepCheck. There is no variable "sleepCheck" because when you first entered the variable on the first line you entered "sleepcheck". Also, after the function when you call sleepCheck be sure you log the entries.

Lastly, I'm not sure if this would be an issue, is the numHours. I believe in the instructions is says it should be greater than or equal to 8.


#3

Thanks.

When you say "log the entries" do you mean "console.log(sleepCheck(10));"?


#4

Exactly :+1:

This post needs to have more characters