JavaScript: Functions & if/else. I don't know why it is giving me an error message


#1

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

I keep receiving the following error message: 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.

I get this even though it appears to be returning the proper 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!";
}
}
sleepCheck(10)


#2

HI you string should be

"You're getting plenty of sleep! Maybe even too much!"

instead of

"You're getting plenty of sleep!  Maybe even too much!"

the diff is that you have a extra space before Maybe


#3

A post was split to a new topic: I'm also having troubles with this particular code


#4

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