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.

1 Like

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

1 Like

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:
First
Attempt
In
Learning

I hope this helps =)

2 Likes

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;
}