You slept NaN hours less than you needed to this week


#1
const getSleepHours = day => {
switch (day) {
  case 'Monday': return 8;
  case 'Tuesday': return 8;
  case 'Wednesday': return 8;
  case 'Thursday': return 8;
  case 'Friday': return 8;
  case 'Saturday': return 8;
  case 'Sunday': return 8;
           }
};
const getActualSleepHours = () => {
  getSleepHours('Monday') +
  getSleepHours('Tuesday') +
  getSleepHours('Wednesday') +
  getSleepHours('Thursday') +
  getSleepHours('Friday') +
  getSleepHours('Saturday') +
  getSleepHours('Sunday');
  return getSleepHours;
};

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

const calculateSleepDebt = () => {
  const actualSleepHours = getActualSleepHours;
  const idealSleepHours = getIdealSleepHours;
  if (idealSleepHours === actualSleepHours) {
    console.log('Wow, you\'re sleep schedule is perfect! Keep it up!');
  }
 if (idealSleepHours < actualSleepHours) {
    console.log('You are sleeping too much! Wake up earlier.');
  }
 if (idealSleepHours > actualSleepHours) {
    console.log('Go to sleep earlier! Or take a nap! You slept ' + (idealSleepHours - actualSleepHours) + ' hours less than you needed to this week.');
  }
}
calculateSleepDebt();

My full code. When I run the program I get the following:

Go to sleep earlier! Or take a nap! You slept NaN hours less than you needed to this week.

I am having at least two errors here that I can’t figure out. the idealSleepHours > actualSleepHours is always the line to run despite what numbers i have entered, and I am getting the ‘Not a Number’ response but I am having trouble figuring out my mistake. Any help?


#2

Those are both supposed to be function calls that invoke the respective functions.


#3

So what would be the proper syntax? I am still unsure as to what I SHOULD be putting instead.

Also is that the only error I have?


#4

Cannot yet say. It’s the one that jumps out. Fix that and test again. If there are any more errors they should raise an exception.

my_function()

The parens are needed to invoke the function.


#5

When the parentheses are included, i get a blank ‘log’ box. No errors and to text whatsoever.


#6

Move the return to the first line and remove the last line.

return getSleepHours('Monday') + ...

#7

Excellent! Now it is running as intended. Thank you for the assistance.