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


#1

Please can someone tell me what is wrong with code? It is returning correct values in results screen and also it works fine when I run on Google Chrome console.

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

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


#2

Seems like your missing an exclamation point at the end of your sentence. Anyway your syntax seems to be ok the problem is probably a typo in your messages. If you can't find them copy and paste the messages from the instructions that is not the important part of the exercise. Although being careful about typos is important in programming.


#3

Thank you. When I read your reply, I thought you must be joking but you are absolutely right. I've added the "!" mark and solved it. It is frustrating but I'm here for a purpose and better follow the rules of the game.

Thank you again!


#4

Thanks guys. Had the same problem, but with the "Get some more shut eye!" part. Be wary and do everything the lesson tells you to do!


#5

My syntax matches, braces are where they should be, semicolons added. What is going on here???


#6

No, idea and it is impossible to find out if you don't post your code. But please do it in an own thread and don't revive a dead thread if you have nothing on topic. Thanks.


#7

I figured this issue out. The error is being triggered when 2 spaces are entered between the, "!" and "Maybe" of the first return statement. Check to see if you entered 2 spaces, if so, delete one and you should be good to go!

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

Thank you..nearly i spend 4 hours to execute this code..finally your answer help me a lot..i learn the importance of Typo in the program