Sleep Debt Calculator Activity - what am i doing wrong?

const getSleepHours = day => {
if (day === ‘monday’) {
return 8;
} else if (day === ‘tuesday’) {
return 8;
} else if (day === ‘wednesday’) {
return 8;
} else if (day === ‘thursday’) {
return 7;
} else if (day === ‘friday’) {
return 8;
} else if (day === ‘saturday’) {
return 7;
} else {
return 8;
}
}

console.log(getSleepHours(‘friday’));
console.log(getSleepHours(‘monday’));
console.log(getSleepHours(‘thursday’));
console.log(getSleepHours(‘sunday’));

const getActualSleepHours = () => {
getSleepHours(‘Monday’)

  • getSleepHours(‘Tuesday’)
  • getSleepHours(‘Wednesday’)
  • getSleepHours(‘Thursday’)
  • getSleepHours(‘Friday’)
  • getSleepHours(‘Saturday’)
  • getSleepHours(‘Sunday’)
    return totalSleepHours;

}

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

console.log(getActualSleepHours());

This is my error
8
8
7
8
/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/sleepDebtCalculator.js:32
return totalSleepHours;
^

ReferenceError: totalSleepHours is not defined
at getActualSleepHours (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/sleepDebtCalculator.js:32:10)
at Object. (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/sleepDebtCalculator.js:41:13)
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)

Hi @kyndra_laurie

Based from the error itself, it’s suggesting you to declare that missing variable within the ES6 function syntax you have created.

const getActualSleepHours = () => {

    // let totalSleepHours = 0; 

    getSleepHours('Monday');
    getSleepHours('Tuesday');
    getSleepHours('Wednesday');
    getSleepHours('Thursday');
    getSleepHours('Friday');
    getSleepHours('Saturday');
    getSleepHours('Sunday');

    return totalSleepHours;
}

I think your objective here is to add up the hours hence you’d need to place them in a formula and store it within totalSleepHours variable in order for the result to be returned.

return totalSleepHours = getSleepHours('Monday') + getSleepHours('Tuesday') + ... (continue your patterns) ;

Hope this simple reminder can help.