Functions if/else recap false error


#1

I keep getting an error on my code and I can't place what is wrong. The error says it's not returning, but it is printing the correct messages on the console. Doesn't that indicate that the function is in fact returning?


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


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.


var sleepCheck = function(numHours){
  if(numHours >=8 ){
      return "Your'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

all that extra white space between too and much is that also in your code like that or a copy/paste mishap?

Also, the task doesn't say you have to console.log the result, maybe that is tripping it up


#3

It was in the code. I took it out but I still get the same error


#4

try removing the console.logs and just call the function


#5

Took them out, same errors
But the fact that it's still displaying in the console mean's that it's returning right?


#6

In cases like this it's most often spelling or white space errors. The "error checker" is looking for excactly the same string as specified in point 02.

My eyes are too tired to distinguish fine detail. Try copy pasting the string form 02.


#7

I was a spelling error :smile:
I guess my eyes are tired too!
Thanks for your help!


#8

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