# I need help on Sleep Calculator Exercise, PLEASE

I really need help, I have been working on this forever this evening. Any help or pointers is much appreciated

``````
const getSleepHours = (day) => {
switch (day) {
case 'monday':
return 8
break
case 'tuesday':
return 7
break
case 'wednesday':
return 6
break
case 'thursday':
return 5
break
case 'friday':
return 4
break
case 'saturday':
return 3
break
case 'sunday':
return 2
break
default:
return 'error'

}
}
const getActualSleepHours = () => {
getSleepHours('monday')+getSleepHours('tuesday')+getSleepHours('wednesday')+getSleepHours('thursday')+getSleepHours('friday')+getSleepHours('saturday')+getSleepHours('sunday')
}
const getIdealSleepHours = () => {
idealHours = 8
return idealHours * 7
}
const actualSleepHours = getActualSleepHours()
const idealSleepHours = getIdealSleepHours()
leftovers = idealSleepHours - actualSleepHours
const calculateSleepDebt = () => {
if (actualSleepHours === idealSleepHours) {
console.log('Great!  You have the perfect amount of sleep!')

} else if (actualSleepHours > idealSleepHours) {
console.log('Wow!  You are sleeping more than you want to!  You can cut back on' + (leftovers) + 'hours of sleep!')

} else {
console.log("Whoa!  You are not getting enough sleep.  Get an additional" + (leftovers) + "additional hours of sleep to go back on track!")
}
};
calculateSleepDebt()
``````

I looked at parts of the code
and I found the following:

``````leftovers = idealSleepHours - actualSleepHours
``````

should probably be

``````const leftovers = idealSleepHours - actualSleepHours;
``````

Also, in

``````  console.log('Wow!  You are sleeping more than you want to!  You can cut back on' + (leftovers) + 'hours of sleep!')
``````

You probably want extra spaces in the string before and after the `+ (leftovers) +`

Also, `leftovers` would be a negative number here, so `(leftovers)` should be `(-leftovers)` to make it positive only on that line.

Also, in case you want your` calculateSleepDebt` function to return the sleep debt,
it should return the difference between `idealSleepHours` and `actualSleepHours`,
and with what you have so far, that would mean having

``````  return leftovers;
``````

at the end of that function.

you are missing the return in the `getActualSleepHours` function.

In the `getIdealSleepHours` function,
`idealHours = 8` should probably have a `let` or `const` in front of it.

• `getActualSleepHours()` could be implemented without calling `getSleepHours()` . Use literal numbers and the `+` operator to rewrite `getActualSleepHours()` . It should still return the total actual hours slept in the week.
• Some people need to sleep longer than others. Rewrite `getIdealSleepHours()` so that you can pass it an argument, like `getIdealSleepHours(8)` where `8` is the ideal hours per night. Update the call to `getIdealSleepHours()` in `calculateSleepDebt()` too.