I can't seem to understand my error


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

So I don't seem to find my mistake, it says; SyntaxError: Unexpected identifier

Can someone help me?


Your error is caused by this line,
if("your amount of sleep" is 8 >=)


Okay..So what should I do to change it? o.O but thank ^^


What looks wrong? Think about what you're doing.


if("your amount of sleep" is 8 >=)

this is not how conditions work. Really. "your amount of sleep" should actually be represented by the number stored in numHours so better use this instead. Also is is not a key word in JS or at least not used like this. And the >= operator compares the values of the stuff that is on the left and right of it. In your case there is nothing on the right. So I really would suggest that you make a review on how conditions in JS work.

Last but not least be careful with your {}, you seem to be missing a { after if but you have an additional } after it and unfortunately that doesn't cancel out positively :wink:.


Thanks a lot :3 I've been having a hard time lately and you've really helped :3


No sry but conditions are really important and you should learn about them before you go on.
In this case it should look something like this:

if(numHours >= 8){

still I'd strongly recommend that you review that part.


That is what I'm doing right now and I have my notes right in front of me I forgot all about that part that's all ._.


Ok, no problem. Are the answers sufficient or do you need some more hints or maybe further explanation on topics. Just say so.


So reviewed over what I seemed to have trouble with and I copied down some more notes but there's still something wrong about what I did and it's starting to bug me..

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

I'm not sure what is wrong and I corrected the ''If ("numHours"" part and the parentheses but now it's telling me,;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.

I don't know.. .-.


numHours is a variable, it doesn't require quotes. You should consider reviewing what you've learned so far. You're also missing a closing bracket.


Gawd I think I'll review the whole thing thanks to you too:3


Ok that's better. There are still 2 issues with this code. The first is the condition:

"numHours" >= 8

currently you use "numHours" which is a string but what you really want to use here is the variable numHours that you declared as the parameter of the function here:

var sleepCheck = function(numHours)

So because running the function with a value of 10 by using sleepCheck(10) will assign a value of 10 to numHours. You end up comparing a number to a number which makes sense, doesn't it?

Now the other problem is the location of your function call. Currently it is inside of the function at a position where it cannot be reached as both options (if and else) have a return statement inside of them you definitively leave the function before getting there. So just move this after the } of your function.


Well I took out the quotations of the numHours and it said it was fine :3 but thanks ^^ you really helped :3