# Sleep Debt Calculator Help

Hi, i’m on Question 5 of the Sleep Debt Calculator, I wrote a Function to Add two other Function and it won’t return a answer. Can someone help me out? It’s at the very bottom of the script called addingTheTWO

const getSleepHours = (day) => {

switch (day) {
case “Monday”:
return 6;
break;
case “Tuesday”:
return 6;
break;
case “Wednesday”:
return 7;
break;
case “Thursday”:
return 7;
break;
case “Friday”:
return 8;
break;
case “Saturday”:
return 7;
break;
case “Sunday”:
return 9;
break;

default:
return “Error.”

}
};

//console.log(getSleepHours(“Sunday”));
const getActualSleepHours = () =>
getSleepHours(“Monday”)

• getSleepHours(“Tuesday”)
• getSleepHours(“Wednesday”)
• getSleepHours(“Thursday”)
• getSleepHours(“Friday”)
• getSleepHours(“Saturday”)
• getSleepHours(“Sunday”)

const addingTheTwo = () => {
console.log(getActualSleepHours())
console.log(getSleepHours(“Friday”)); //Must Enter with Captial Letter.
console.log(getActualSleepHours + getSleepHours)
};

``````const addingTheTwo = () => {
console.log(getActualSleepHours())
console.log(getSleepHours(“Friday”)); //Must Enter with Captial Letter.
console.log(getActualSleepHours + getSleepHours)
};
``````

You actually need to call the function to execute. Try:

``````const addingTheTwo = () => {
console.log(getActualSleepHours())
console.log(getSleepHours(“Friday”)); //Must Enter with Captial Letter.
console.log(getActualSleepHours + getSleepHours)
};

``````

Still got an Error Message. I don’t think it met the parameters of the question…

Inside the `getActualSleepHours()` function, call the `getSleepHours()` function for each day of the week. Add the results together and return the sum using an implicit `return` .

In the Console.log the answers are printed separately, but the question suggests it is looking for a Sum Total? Can You Help? The answer is below and below the answer is my code I wrote.

50
8
() =>
getSleepHours(“Monday”)

• getSleepHours(“Tuesday”)

• getSleepHours(“Wednesday”)
• getSleepHours(“Thursday”)
• getSleepHours(“Friday”)
• getSleepHours(“Saturday”)
• getSleepHours(“Sunday”)(day) => {

switch (day) {
case “Monday”:
return 6;
break;
case “Tuesday”:
return 6;
break;
case “Wednesday”:
return 7;
break;
case “Thursday”:
return 7;
break;
case “Friday”:
return 8;
break;
case “Saturday”:
return 7;
break;
case “Sunday”:
return 9;
break;

default:
return “Error.”

}
}

Sleep Debt Calculator
7/12 Complete

const getSleepHours = (day) => {

switch (day) {
case “Monday”:
return 6;
break;
case “Tuesday”:
return 6;
break;
case “Wednesday”:
return 7;
break;
case “Thursday”:
return 7;
break;
case “Friday”:
return 8;
break;
case “Saturday”:
return 7;
break;
case “Sunday”:
return 9;
break;

default:
return “Error.”

}
};

//console.log(getSleepHours(“Sunday”));
const getActualSleepHours = () =>
getSleepHours(“Monday”)

• getSleepHours(“Tuesday”)
• getSleepHours(“Wednesday”)
• getSleepHours(“Thursday”)
• getSleepHours(“Friday”)
• getSleepHours(“Saturday”)
• getSleepHours(“Sunday”)

const addingTheTwo = () => {
console.log(getActualSleepHours())
console.log(getSleepHours(“Friday”)); //Must Enter with Captial Letter.
console.log(getActualSleepHours + getSleepHours)
};

I am able to see a couple of wrong function declarations and calls.

Can you tell me what the method getActualSleepHours() is trying to do here? That method is having wrong syntax for declaration.
If you’re trying to get the sleep hours on monday, then you don’t need to declare it as a method. It would just be a variable:

`const getActualSleepHours = getSleepHours("Monday");`

Apart from that, there are various calls to getSleepHours() method which aren’t doing anything technically since you’re not logging their answers to console nor storing them in a variable. I’m talking about these calls.

``````getSleepHours(“Tuesday”)

* getSleepHours(“Wednesday”)
* getSleepHours(“Thursday”)
* getSleepHours(“Friday”)
* getSleepHours(“Saturday”)
* getSleepHours(“Sunday”)
``````

I don’t think you’re copying the code correctly and pasting it here.

Could you try and explain the goal that you’re trying to attain with the code here? Meanwhile, have a look at this code, I’ve fixed the errors and that should run from my perspective assuming I’m doing exactly what you wanted to do with it.

``````const getSleepHours = (day) => {

switch (day) {

case "Monday":

return 6;

break;

case "Tuesday":

return 6;

break;

case "Wednesday":

return 7;

break;

case "Thursday":

return 7;

break;

case "Friday":

return 8;

break;

case "Saturday":

return 7;

break;

case "Sunday":

return 9;

break;

default:

return "Error."

}

};

console.log(getSleepHours("Sunday"));

const getActualSleepHours = getSleepHours("Monday");

getSleepHours("Tuesday")

getSleepHours("Wednesday")

getSleepHours("Thursday")

getSleepHours("Friday")

getSleepHours("Saturday")

getSleepHours("Sunday")

const addingTheTwo = () => {

// console.log(getActualSleepHours())

console.log(getSleepHours("Friday")); //Must Enter with Captial Letter.

// console.log(getActualSleepHours() + getSleepHours())

};