Sleep Debt Calculator - JavaScript Project Question

Hi there,

I’m currently working through the Sleep Debt Calculator JavaScript project and am having some trouble understanding what I need to do in Step 4.

The instructions read:
"Now that you’ve written a function to get the sleep hours for each night, we need to do three things:

  • Get the total sleep hours that you actually slept
  • Get the ideal sleep hours that you prefer
  • Calculate the sleep debt, if any.

To get the total sleep hours that you actually slept, create a new function named getActualSleepHours that takes no parameters."

This seems straight-forward however the hint (below) confuses me as it contains code that hints that I need to set up two functions when the instruction calls for setting up one:

Hint
const getSleepHours = day => {

};

const getActualSleepHours = () => {

};"

My code so far is:

const day = getSleepHours => { getSleepHours === (('monday' || 'tuesday' || 'wednesday' || 'thursday' || 'friday' || 'saturday' || 'sunday')); }; const hoursSlept = day => { day = day.toLowerCase(); if (day === 'monday') { return 6 } else if (day === 'tuesday') { return 8 } else if (day === 'wednesday') { return 5 } else if (day === 'thursday') { return 6 } else if (day === 'friday') { return 7 } else if (day === 'saturday') { return 8 } else if (day === 'sunday') { return 9 } else { return 'Please enter a valid weekday as a variable'; } }

What am I missing here? I feel like I am overlooking or not understanding something in the question. Whilst I could blindly follow the hint, I like to understand why I would do that.

The URL to the project is here:
https://www.codecademy.com/courses/introduction-to-javascript/projects/sleep-debt-calculator

Thanks for your help.
Brendon

Hi Brendon - if you click “Get Unstuck” in the top right corner, you can watch a video where someone from Codecademy completes the exercise while explaining what they do, hopefully that helps a bit!

1 Like

Thanks Cassian,

Turns out my code had quite a few logical mistakes through it and I’ve now got it going.

Brendon

1 Like