What happened?


#1


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

When I type in my code, it only gives me one message even though I've called the function three times, and the message is incorrect.


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


#2

After your return statement inside your else statement you have a ' instead of a semicolon.
Also you should be checking if numHours is more or less, not sleepcheck


#3

thanks, and that ' was a typo; it was supposed to be a semicolon


#4

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

Where is error. I do not find it. Print 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."


#5

Your error comes from your else statement. It is incorrect syntax to have anything inside parentheses after an else statement.
Corrected else:

else {
    return "Get some more shut eye!";
}

#6

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