Sleep Debt Calculator actualSleepHours not defined error

So here is my code:

const getSleepHours = (day) => {
  if (day === 'monday') {
    return 8;
  } else if (day === 'tuesday') {
    return 7;
  } else if (day === 'wednesday') {
    return 8;
  } else if (day === 'thursday') {
    return 6;
  } else if (day === 'friday') {
    return 7;
  } else if (day === 'saturday') {
    return 9;
  } else if (day === 'sunday') {
    return 9;
  } 
};
const getActualSleepHours = () => getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday');
const getIdealSleepHours = () => {
   const idealHours = 7;
  return idealHours * 7;
};
const calculateSleepDebt = () => {
  const actualSleepHours = getActualSleepHours();
  const idealSleepHours = getIdealSleepHours();
};
if (actualSleepHours === idealSleepHours) {
   console.log('You slept the perfect amount');
} else if (actualSleepHours < idealSleepHours) {
   console.log('You need to get some rest!');
} else {
   console.log('I think you slept too much!')
}

I continually receive an error declaring actualSleepHours not being defined, but it is, within the function. All the messages I’ve read mention that because it is defined within the function it is an issue, but as I am just starting to learn JavaScript and coding in general, I am afraid it is not yet making sense to me.
Any help educating me would be greatly appreciated

EDIT: code has been updated to its current form 01AUG19 5:40PM

1 Like

The variable is scoped to the function so cannot be seen by the rest of the program.

There is no function by that name.

1 Like

My bad
actualSleepHours() was a leftover from when I tried calling it as a function instead of a variable to see if that would work.
How would I structure it so that it is not longer scoped to the function? Because I have it set to exactly what the hint shows, and that was written as such -before- I even looked there.

1 Like

Might wanna look at where the function begins and ends, you probably already have the right idea

1 Like

As near as I can tell this is the problem code:

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

I just cannot figure out what exactly about that is wrong, since it is verbatim the hint code as well.

1 Like

Is that everything that the function should do? Create two variables and then not use them.
What should it do?

1 Like

…you are not honestly telling me that the dang if/else if/else statement was supposed to be in that block this whole time.

2 Likes

I’d never give you a straight answer about anything, so no.

2 Likes

So I moved the closing bracket to encompass the whole if statement set, and now am no longer getting an error, so PLUS! That was silly. Now I just have to figure out how to get the return to actual post to console. Thanks for the help! I might be back later for that
EDIT:
it really helps if you call the function that is supposed to run to print to console instead of just assuming the results output by themselves. DERP
Much obliged! The wording on this whole project at that point plus checking the hint for confirmation, gave a bit of a misdirection towards the placement of the if statements. I will be on the watch for that next time!!!

1 Like