Hello all,
I am new to coding and new to the forum, so please forgive me if I have posted anything incorrectly.
Project source: https://www.codecademy.com/courses/introduction-to-javascript/projects/sleep-debt-calculator
I am struggling with Step 5 of this project (specifically this bit " Add the results together and return the sum using an implicit return
.")
Here is what I have -
const getSleepHours = day => {
if (day === 'monday') {
return '8';
} else if (day === 'tuesday') {
return '7';
} else if (day === 'wednesday') {
return '6';
} else if (day === 'thursday') {
return '7';
} else if (day === 'friday') {
return '8';
} else if (day === 'saturday') {
return '6';
} else if (day === 'sunday') {
return '7';
} else {
return 'invalid'
}
};
const getActualSleepHours = () =>
getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday');
// These all return the correct hours
console.log(getSleepHours('monday'));
console.log(getSleepHours('tuesday'));
console.log(getSleepHours('wednesday'));
console.log(getSleepHours('thursday'));
console.log(getSleepHours('friday'));
console.log(getSleepHours('saturday'));
console.log(getSleepHours('sunday'));
//This doesn't add the hours, just returns a list of them
console.log(getActualSleepHours());
I don’t get any errors messages, just a list of 8767867 instead of 49. What have I done wrong/ how do I correct it?