Syntax Problems | Number 12


I really don't know what is the problem, but it says that "SyntaxError: Unexpected token {"
For curly brackets, and not sure what to do. I've been thinking "Have I needed to put it here or not?" and vice versa "Do I need to not put it here?"

Here is my code.

var sleepCheck = function(numHours) {
if (numHours === 10) {
return "You're getting plenty of sleep! Maybe even too much!";
else (numHours < 8) {
return "Get some more shut eye!";

If it is simple, I am really dumb. lmao


else means everything else. It's unconditional.

firefox -> shift + f4 -> run ->

Exception: SyntaxError: missing ; before statement

Which is to say that this is two statements:

(numHours < 8) {}

And there needs to be a ; between statements.

Which makes the { be unexpected ("SyntaxError: Unexpected token {")


Pleasse Look at THIS Topic Thankyou!

Two Problems


In an else statement its everything ELSE Than the conditions listed above. So your not suppose to have a condition. So instead of this:

Do This:

return "Get some more shut eye!";

Now secondly in your if statement it tells you less than or equal to 8.

So instead of this:

Do this:


Hope this helped. But Please check out the link i provided at first to help you format your code.


Thanks, it worked and I formatted it.


I have a problem, my following script doesn't work.

 var sleepCheck = function(numHours) { 
    if (numHours >= 8) {
        return "You're gerring plenty of sleep! Maybe even too much!";
    else {
        return "Get some more shut eye!";



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.

although I can print the statement.


You've spelt getting wrong here, that could be the problem.


Haha, typing mistake. Thanks so much!


I do the same way to often, stuck on a problem for so long and turns out to be a small spelling mistake. :slightly_smiling: code academy is so strict on you saying exactly what it says it sucks


When it comes to output messages I'd almost agree with you. But on the other hand you need to keep in mind that a small typo in a variable name could change the whole sense of your code so being that strict is also what the language does not only what codecademy does. And btw making small and stupid errors is what almost everybody has to go through when learning to code :slightly_smiling:


Can someone review my code?
I've tried with out the strings in brackets, with the parameter as numhours and numHours, and without and with the console.logs on the function call, and without the semi-colons. Still, I'm not seeing my typo.

function sleepCheck(numHours){
    if {
    numHours >= 8
    return ("You're getting plenty of sleep! Maybe even too much!");
    else {
   return ("Get some more shut eye!");