12 functions and if/else function returns answer but pop up says it's not


#1



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


When I run the code, it says:

"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 don't know why it is saying that because when I test it, it returns the right answer for both numbers less than 8 and more than 8. In other words, it works perfectly except for the popup telling me that it doesn't. I read other forums and changed my code according to what worked for other people, but it's still not working for me. Could anybody tell me what I'm doing wrong and/or how to fix it? That would be greatly appreciated, thank you.


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

@purplelionriley
You will have to use the EXACT text's as are mentioned in the Instructions.


#3

Oh okay, thank you. @leonhard.wettengmx.n


#4

I had almost the same problem (only in my case it said the incorrect answer for 5 hours, when in fact the correct answer was given for sleepCheck(5)
Don't understand???? my code is
// Write your function below.
// Don't forget to call your function!
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);
sleepCheck(5);
sleepCheck(8);


#5

@almac46,
Look at your returned text
and the required text as mentioned in the Instructions.


#6

Thanks - I just realised that my text said shut-eye instead of shut eye (duuuh!!)


#7

What is wrong?

// Write your function below.
// Don't forget to call your function!
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);
sleepCheck(5);
sleepCheck(8);


#8

Hi you didn't closed the sleepCheck function

var sleepCheck = function(numHours) {#open teh function

}#close the function

And

next time it's better if ou create a new topic since that on was from 10 days ago.


#9

i dont get it. whats wrong with the text?