Sleep Debt Calculator Help

been trying to figure out why this is giving me an answer of “17Error!784” in the console. I’m at a lose…

Ok so there’s a couple of issues with your code. But nothing that can’t be fixed!

One thing you should review is what happens when a function “returns” a statement.
In your getActualSleepHours function you are invoking getSleepHours, but you’re not storing the variables anywhere.

Also, you have to have brackets for your getActualSleepHours code block.

Welcome to the forums :slight_smile:

1 Like

I think the getActualSleepHours function is fine as a concise arrow expression.

The output you are getting is suggesting one of your switch comparisons is making it to the default value. Check your spelling carefully :wink:

1 Like

Ah you’re right, I looked at it too hastily. Good catch.


All good brotha - I gotchu!


Since a function stops running as soon as it returns a value, you don’t need the break statements. Having them won’t hurt but they’re not doing anything here. Like @toastedpitabread said, review return and break statements.


Awesome! Thank you everyone for your replies ! Will give it a good once over again.


Does a return statement need to be at the end of the getActualSleepHours function?

No. You have a concise body arrow function. The fat arrow => is essentially saying return. Your issue really is one of spelling. Try calling your getSleepHours() function for each day separately, and logging the result to the console:

Thank you, just wanted to be sure. I finally finished the project and get it working properly. Thank you all for your help!

1 Like