'Sleep Debt Calculator' I'm stuck at point 9

This is my code so far for the exercise:

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 8;
} else if (day === ‘saturday’) {
return 10;
} else if (day === ‘sunday’) {
return 8;
}
}
console.log(getSleepHours(‘tuesday’));

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

const getIdealSleepHours = () => {
const idealHours = 7.5;
return idealHours * 7;
}

console.log(getActualSleepHours());
console.log(getIdealSleepHours());

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

if (actualSleepHours === idealSleepHours) {
console.log(‘You got the perfect amount of sleep’);
} else if (actualSleepHours > idealSleepHours) {
console.log(‘You got more sleep than needed’);
} else {
console.log(‘You should get some rest’);
};

This is the error that shows up for last if statement:
/home/ccuser/workspace/sleep-debt-calculator/sleepDebtCalculator.js:44
if (actualSleepHours === idealSleepHours) {
^

ReferenceError: actualSleepHours is not defined
at Object. (/home/ccuser/workspace/sleep-debt-calculator/sleepDebtCalculator.js:44:5)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3

I don’t know what to do, I don’t know why actualSleepHours is undefined when it is on the previous line. Please help

Note that the variables are in function scope, and are not accessible outside of the function body.

You have a }; in the wrong place.

const calculateSleepDebt = () => {
  const actualSleepHours = getActualSleepHours();
  const idealSleepHours = getIdealSleepHours();
}; // this }; does not belong there

The }; you have after const idealSleepHours ends the the calculateSleepDebt function there.
And since actualSleepHours and idealSleepHours are declared inside the function, they don’t exist outside of the function. (These variables have function scope - they’re only accessible inside the function, as stated by @mtf in the previous post).

To fix that, put the }; after the end of the last else block,
so that all the if, else-if, and else stuff is inside the calculateSleepDebt function.