Https://www.codecademy.com/courses/introduction-to-javascript/projects/sleep-debt-calculator

i keep getting an error saying ReferenceError: actualSleepHours is not defined
at Object.
i’m not sure what the problem is

const getSleepHours = day => {


  if (day === 'monday'){
    return 8;
  }
  else if (day === 'tuesday'){
    return 7;
  }
  else if (day === 'wednesday'){
    return 6;
  }
  else if (day === 'thursday'){
    return 5;
  }
   else if (day === 'friday'){
    return 4;
  }
   else if (day === 'saturday'){
    return 3;
  }
   else if (day === 'sunday'){
    return 5;
  }
   else{
    return 'error';
  }

};
let getActualSleepHours = () => 
  getSleepHours('monday') +
  getSleepHours('tuesday') +
  getSleepHours('wednesday') +
  getSleepHours('thursday') +
  getSleepHours('friday') +
  getSleepHours('saturday') +
  getSleepHours('sunday');
  console.log(getActualSleepHours());

let getIdealSleepHours = () => {
  let idealHours = 8;
  return idealHours * 7;
};
const calculateSleepDebt = () => {
  let actualSleepHours = getActualSleepHours();
  let idealSleepHours = getIdealSleepHours();
}
if (actualSleepHours === idealSleepHours){
  console.log('you got the perfect!!! amount of sleep')
} else if (actualSleepHours > getIdealSleepHours){ 
  console.log('you got more sleep than needed')
} else if(actualSleepHours < idealSleepHours) {
  console.log('you should get some rest')
} else {
  console.log('.....an error occured')
}

Yes, note your bracketing and note that const calculateSleepDebt = () => is an arrow function declaration.

(Remember anything declared inside a function only lives within its scope).

1 Like