Functions recap if/else. Cant see what is wrong


Can someone please explain where I am going wrong.



You're not printing it so no need to console.log. Simple use sleepCheck() with the number of hours inside the bracket. If you were however, using console.log, you would need an additional closing bracket for each line of code :slightly_smiling: Hope that helps @caroldavies!


¥eah I had the additional bracket still wasnt working. I will try removing the console.log. Thanks


removing the console.log has helped still not working. Error says it something to do with the else. I have refreshed logged out and logged back in. it still is not working. I am using firefox.


Ah wait, I realised what else is wrong. You haven't open braced you 'if' statement. You've used a semicolon instead.

So you should open for the function, open for the if statement, and open for the else statement (and of course close all three).


i have removed the semicolon but there is an { after (numHours)


Need 2 sets of { for some reason


Yep. So that brace after (numHours) is for your function right?

Then for your if statement, you need to open a new brace which closes after the first return statement. Then you open one for else { which closes after the return statement. And then you have the closing brace for the function. Does that make sense?


Sorry, late reply - I guess you worked it out. But in answer to your question around two sets - take a step back and think about it this way. For which lines of code do you need braces?

FUNC { }
IF { }
ELSE { }

So in your structure it would be

FUNC { IF { ELSE { } } }

Get it?


The console.logs are fine and I'd actually recommend to keep the. If you omit the semicolons at the end you only see one "pseudo output" meaning the console just repeats the last value used in the code. With console.logs you'd see all three function calls correctly displayed. But you're correct about the missing ) at the end.

And about the semicolon you may have a look at this longer explanation here:


Hi, i need help about this , I can`t find any problems with my cintax


The syntax seems to be ok, I'd go for typos in the output message. Just copy and paste them.


That`s what i tought , but i all ready try that, and still not working...:slightly_smiling:


suddenly it`s working...