# Sleep Debt Calculator - getActualSleepHours is not a sum

Hi everyone!

I’m pulling my hair out on 5th step of the Sleep Debt Calculator project in the Javascript section of the Front-End career path. I may be missing a simple small thing, but I just can’t see it…

The getActualSleepHours function is supposed to return the sum of the hours of sleep of each day. But in my case, when I console.log it, it just returns the 7 values of each day, side by side - in my case: 87685810 (8 hours on monday, 7 on tuesday and so on…).

Here is my code, any of you can spot what I’ve done wrong?

const getSleepHours = day => { day= day.toLowerCase(); switch (day) { case 'monday': return '8'; break; case 'tuesday': return '7'; break; case 'wednesday': return '6'; break; case "thursday": return '8'; break; case'friday': return'5'; break; case 'saturday': return '8'; break; case 'sunday': return '10'; break; default: return 'Error! Invalid day.'; } } console.log(getSleepHours('Sunday')); const getActualSleepHours = () => getSleepHours('Monday') + getSleepHours('Tuesday') + getSleepHours('Wednesday')+ getSleepHours('Thursday') + getSleepHours('Friday') + getSleepHours('Saturday') + getSleepHours('Sunday') const getIdealSleepHours = () => { const idealHours = 8; return idealHours*7; } console.log(getActualSleepHours());

Hey,
the problem is that you return the single sleeping hours values as strings from the getSleepHours function. That way your getActualSleepHours functions just does string concatenation rather than a calculation.
Return numbers rather than strings from getSleepHours such as:

``````case 'monday':
return 8;
``````

It’s obvious now that you’ve pointed that out, thanks a lot!!

1 Like