Hello, Everyone!
I am currently working on this project and it’s driving me crazy! I followed the instructions as best as I could but when I got to step 9 I called the function and nothing happens. When I log it to the console it just says “Undefined”.
Can someone show me what I am doing wrong?
const getSleepHours = day => {
if (day === 'monday') {
return 8;
} else if (day === 'tuesday') {
return 7;
} else if (day === 'wednesday') {
return 5;
} else if (day === 'thursday') {
return 6;
} else if (day === 'friday') {
return 3;
} else if (day === 'saturday') {
return 9;
} else if (day === 'sunday') {
return 4;
} else {
console.log('Check Code.');
}
};
const getActualSleepHours = () => {
getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday');
};
const getIdealSleepHours = () => {
let idealHours = 8;
return idealHours * 7;
};
const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours();
if (actualSleepHours === idealSleepHours) {
console.log('You got the perfect amount of sleep!');
} else if (actualSleepHours > idealSleepHours) {
console.log('You got more sleep than needed!');
} else if (actualSleepHours < idealSleepHours) {
console.log('You got less sleep that you needed. Get some rest!');
}
};
calculateSleepDebt();