12. Functions & if else - What am I doing wrong ? Please advice!


Could someone please check the code and see where am I wrong ? The error I get is " SyntaxError: expected expression, got keyword 'else'" . Can't figure out what is wrong! Thanks in advance!


var sleepCheck = function (numHours) {

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


if (numHours >=8); <----------- {

so the problem is that you have a " ; " where I put the arrow. just a simple syntax error, but the computer misunderstood it.
just remove the semicolon and it should run


Thank you!! Was stuck forever!!


That helped me, too! Thanks!


No problem!! I'm happy I could help both of you.


Hi, I did exactly same as the code above.
But it didn't work.
So i did the code like below.
It's still not working.
I don't find a syntax error. Please help me out !

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

var advice=sleepCheck(5)


Try (numHours) instead of (numhours)


Thanks for the answer.
I tried (numHours) as well as ("") in console.log like below.
but still i get the syntax error.

var advice = sleepCheck(5)


Hey everybody,
I'm also having the same problem. I'm getting an error message "SyntaxError: Unexpected token =".
I have tried all the solutions above but still not working. I'll appreciate your help. Thank you!

Here is my code:

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


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