Sleep Debt Calculator - what am I doing wrong!

Hi there,
I’m completely stuck on the Sleep Debt problem. I even followed the course instructors code exactly and it’s still not working! Can anyone please take a look at my code and tell me what is wrong with it?

const getSleepHours = day => {

if(day === “Monday”) {
console.log(8);
} if
(day === “Tuesday”) {
console.log(6);
} if
(day === “Wednesday”) {
console.log(7);
} if
(day === “Thursday”) {
console.log(7);
} if
(day === “Friday”) {
console.log(7);
} if
(day === “Saturday”) {
console.log(9);
} if
(day === “Sunday”) {
console.log(7);
}
};

const getActualSleepHours = () =>

getSleepHours(“Monday”) +
getSleepHours(“Tuesday”) +
getSleepHours(“Wednesday”) + getSleepHours(“Thursday”) +
getSleepHours(“Friday”) +
getSleepHours(“Saturday”) +
getSleepHours(“Sunday”);

console.log(getSleepHours(“Monday”));
console.log(getActualSleepHours());

I’ve tested the getSleepHours function and that works fine but when I console.log the getActualSleepHours, I keep on getting NaN. So confused because I’ve even ended up copying the tutorial video code exactly and it’s still doing it!

Thanks so much in advance.

1 Like

The function getActualSleepHours needs a return value from the getSleepHours function. But you just log the hours, so getActualSleepHours. gets nothing to work with.

When you post code in the forum, please make sure it’s properly fomatted.

4 Likes

THANK YOU! That fixed it completely. :smiley:

Really appreciate your taking the time.

2 Likes