Sleep debt calculator - why that the actual sleep hours don't add up?

Hello All, I would hope that someone can answer me on this:

Why that my actual sleep hours don’t add up? When being called, they are just listed one after the other, and ended with NaN. I know the problem might be at the switch part, but what did i do wrong during the switch?

Many thanks!

1 Like

Your function writes stuff to screen but doesn’t make the result available to other parts of your code.

It might help you to see the situation for what it is if you commented out the calls to console.log, printing is probably not what that function should be doing anyway.


you should be returning the values. Console.log will print values.


Thank you I got it now!

1 Like

Thanks! Stupid mistake. Thanks! :slight_smile:

1 Like

Don’t think its stupid. Everyone makes mistakes. Know its just a FAIL, which is a:

I hope this helps =)


Thanks for the encouragement! :slight_smile:

1 Like

Your welcome. Glad that helped :slightly_smiling_face:

1 Like

someone could help to check what is the error on “console”, which I copied the mistake from F12, thank you

SCRIPT1004: SCRIPT1004: Expected ‘;’

else (day === ‘Sunday’) {
return 5;

Hi there, I’m just learning and it’s maybe too late for a response, but I didn’t see one…

I’ve also received errors when using the last else statement because I add an expression next to it, when it shouldn’t be since the else will gather everything that don’t fall in the previous if statements. I hope this make sense.