Exercise link: https://www.codecademy.com/courses/introduction-to-javascript/projects/sleep-debt-calculator
Here is the code I have so far:
let getSleepHours = (day) => {
if (day === ‘monday’){
return ‘8’;
} else if (day === ‘tuesday’){
return ‘7’;
} else if (day === ‘wednesday’){
return ‘8’;
} else if (day === ‘thursday’){
return ‘8’;
} else if (day === ‘friday’){
return ‘9’;
} else if (day === ‘saturday’){
return ‘7’;
} else if (day === ‘sunday’){
return ‘8’;
}
};
const getActualSleepHours = () =>
getSleepHours(‘monday’) +
getSleepHours(‘tuesday’) +
getSleepHours(‘wednesday’) +
getSleepHours(‘thursday’) +
getSleepHours(‘friday’) +
getSleepHours(‘saturday’) +
getSleepHours(‘sunday’);
;
console.log(getActualSleepHours());
Why do the results for each day of the week get concatenated instead of added? The result I get is 8788978, and I cannot figure out why they will not add. If I insert any operator other than a plus sign, the math works.