12/13 Syntax Error?


#1

I keep getting a syntax error in 12/13
(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.)

this is my code
// 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! Mayeb even too much!");
}
else {
return ("Get some more shut eye!");
}
}
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

i'm not quite sure what i'm doing wrong here. When I run the code the console displays the appropriate response but I'm still getting an error.

Any help is much appreciated!


#3

It's the spelling "Maybe" you wrote "Mayeb"

return "You're getting plenty of sleep!Mayeb even too much!";

I too happen a lot. I guess we got error when we spelled wrong the given statements is because of Codecademy input codes. We had to get right sentences as they inputed. When we write our own codes in text editors, I think it will just appear as you typed (as spelling wrong) in your program. Just my two cents here, I hope someone would correct me if my guess is wrong. ^^


#4

HI, I also have some problem with that exercise, I know later on IIll figure it out ,.... but well

A question: why do you include () in return
return (" ")
isnt it or isnt it goes without the () ??

what kind or error does it give yoou??
I run it , and Its good!! the output is correct-


#5

It doesn't really matter if you put the parentheses or not when returning something. Things like console.logs must need parentheses, but return statements may or may not include parentheses.

P.S. It's a good habit to do so though :smiley:


#6

Thank you for the responses and help! I can't believe that it was a simple misspelling of maybe that had everything thrown off. I'll make sure to start double checking my spelling when I get errors.


#7

Same here. Who would think that my "double space after return" habit from High School typing class would cause this much frustration. :confused:


#8

getting things spelled incorrectly is definitely one of the most common mistakes I see in a lot of these questions in the forum!