Sleep Debt Calculator Project

I want the function to compare the actualSleepHours variable with the idealSleepHours variable. To fix this, I added the console.log statement and I also added a return statement to the getActualSleepHours function:

const getActualSleepHours = () =>
getSleepHours(‘monday’) + getSleepHours(‘tuesday’) + getSleepHours(‘wednesday’) + getSleepHours(‘thursday’) + getSleepHours(‘friday’) + getSleepHours(‘saturday’) + getSleepHours(‘sunday’);
return getActualSleepHours();

const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours();

However now nothing is appearing at all in the console…wop wop!

that’s not a valid function

what you’re doing right now is writing a bunch of code and running it and then it doesn’t work and you don’t know what to do.

better is if you write a small piece of code, test it a bit, then write another piece, test that, and so on. then you have several small functioning pieces.

so for example, you’d write your function getActualSleepHours, and then maybe you would add a call to it at the bottom of your code and print out the result so that you can see that it does its job.

maybe you have some other functions that you need, you’d do the same thing for those.

Then you’d start on your calculateSleepDebt. Perhaps you would start by making it just print “hi”, and then you’d call it to see whether hi is indeed being printed, and then you add something more, maybe you’d print that out too and run it to see if that’s okay, and so on until you’re done

Thanks for your help everyone; I went over the basics of JS again and realised that I had input code to run for my “else” statement when I wasn’t meant to. Another problem was with local variables coming up as “not defined”. I finally got it working in the end and was able to do some of the extra practice at the very end of the activity as well.