Sleep debt not summing?

I’m working through the Sleep Calculator exercise and I’m running into the darnedest thing – when I call getActualSleepHours(), rather than giving me the sum of all the days, it lists each day one at a time. I watched the video and as far as I can tell it’s basically the same. I’m not getting an error, either – just the values listed out. Here’s the code:

function getSleepHours(day) {
  switch (day) {
    case 'monday': 
      console.log(8)
      break;
    case 'tuesday': 
      console.log(7)
      break;
    case 'wednesday': 
      console.log(6)
      break;
    case 'thursday': 
      console.log(7)
      break;
    case 'friday': 
      console.log(8)
      break;
    case 'saturday': 
      console.log(5)
      break;
    case 'sunday': 
      console.log(3)
      break;
    default: 
    return 'error!';
  }
}

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

getActualSleepHours()

And when I run it, this is the output:

8
7
6
7
8
5
3

I’m stuck. Halp? [edit: I tried working through to the end and it still does the same thing when I call calculateSleepDebt(), rather than either the “enough sleep” or “not enough sleep” log.

OOP nevermind, I was console.logging the hours per day, not returning them.

2 Likes