Another SDC (Sleep Debt Calculator) Guy Gets Stuck

No errors, but nothing is produced into the console when I execute this… What am I missing and how can I debug in the future?

const getSleepHours = day => {
  if (day === 'Monday') {
    return 7;
  } else if (day === 'Tuesday') {
    return 7;
  } else if (day === 'Wednesday') {
    return 7;
  } else if (day === 'Thursday') {
    return 7;
  } else if (day === 'Friday') {
    return 8;
  } else if (day === 'Saturday') {
    return 8;
  } else if (day === 'Sunday') {
    return 7;
  }
}

const getActualSleepHours = () =>
getSleepHours('Monday') + getSleepHours('Tuesday') + getSleepHours('Wednesday') + getSleepHours('Thursday') + getSleepHours('Friday') + getSleepHours('Saturday') + getSleepHours('Sunday');

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

const calculateSleepDebt = () => {
  const actualSleepHours = getActualSleepHours();
  const idealSleepHours = getSleepHours();
  
  if (actualSleepHours === idealSleepHours) {
    console.log('You got the perfect amount of sleep.');
    
  } else if (actualSleepHours > idealSleepHours) {
    console.log('You got ' + (idealSleepHours + actualSleepHours) + ' hour(s) more sleep than you needed this week. Get some rest.');
    
  } else if (actualSleepHours < idealSleepHours) {
    console.log('You got ' + (idealSleepHours - actualSleepHours) + ' hour(s) less sleep than you needed this week. Get some rest.');
    
  } else {
    console.log('Error');
   }
  };

calculateSleepDebt();

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

I imagine you are not producing nothing in the console. You should be seeing Error in the console because you should be calling getIdealSleepHours on the 2nd line of calculateSleepDebt, not getSleepHours.

1 Like

Yes, that’s right. I was getting “Error” – I adjusted the code once more before posting. Sorry about that.

Thank you for finding the error! I checked over it multiple times but simply did not see it…