# Hi everyone, I am currently stuck on SleepDeptCalculator

``````  if (day === "Monday") {
return 8;
} else if (day === "Tuesday") {
return 7;
} else if (day === "Wednessday") {
return 6;
} else if (day === "Thursday") {
return 7;
} else if (day === "Friday") {
return 8;
} else if (day === "Saturday") {
return 8;
} else if (day === "Sunday") {
return 5;
} else {
return "Error";
}
};

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

const getActualSleepHours = () =>

getSleepHours("Monday") +
getSleepHours("Tuesday") +
getSleepHours("Wednessday") +
getSleepHours("Thursday") +
getSleepHours("Friday") +
getSleepHours("Saturday") +
getSleepHours("Sunday");

console.log(getActualSleepHours());

const getIdealSleepHours = () => {
let idealHours = 8;
return idealHours * 7;
};

// const getIdealSleepHours = idealHours => idealHours * 7;

console.log(getIdealSleepHours());

const calculateSleepDebt = () => {
let actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours();

// const idealSleepHours = getIdealSleepHours(8);

if ((actualSleepHours = idealSleepHours)) {
console.log("You got the perfect amount of sleep!.");
} else if (actualSleepHours > idealSleepHours) {
console.log(
"You got " +
(actualSleepHours - idealSleepHours) +
"more sleep than needed!."
);
} else if (actualSleepHours < idealSleepHours) {
console.log(
"You need to get some rest because you've slept" +
(idealSleepHours - actualSleepHours) +
"less this week!."
);
} else {
console.log("Something went wrong!.");
}
};

calculateSleepDebt();

``````

Hi, every time I save my code, it keeps giving the same answer of user getting perfect sleep even after I change my return values. I guess something is not right in my else if statements, but i’ve been trying to find the error for over an hour. I would really appreciate the help!.
I was also getting an error of assigning to a constant variable in the calculateSleepDebt, but i changed from const to let and it worked, but when i watched the walkthrough video, Galina’s code ran on the const variable.
p.s - the code in comments are my attempts of step 12 which is also giving and error message.

The first thing I notice is this:

``````const getActualSleepHours = () => 6 + 7 + 9 + 8 + 5 + 10 + 11;
getSleepHours("Monday") +
getSleepHours("Tuesday") +
getSleepHours("Wednessday") +
getSleepHours("Thursday") +
getSleepHours("Friday") +
getSleepHours("Saturday") +
getSleepHours("Sunday");
``````

getActualSleepHours returns always the same number because it ends after the semicolon behind 11. The rest will be ignored.

The second thing is this:

``````const getIdealSleepHours = idealHours => {
return idealHours * 7;
};

console.log(getIdealSleepHours());
``````

getIdealSleepHours exprects an argument, but you call it without an argument.

If you post code in the editor, please wrap it in 3 backticks (```) to make it readable.

Hi @mirja_t thank you so much for your contribution. I have added the backticks you said, but the rest of the code still doesn’t work.

`if ((actualSleepHours = idealSleepHours))`
a single equal sign is used for an assignment. What you want to do in the if statement is a comparison (2 or 3 equal signs).

Thank you @mirja_t it works now, you’re a life saver!. But now, i keep getting a NAN for actualSleepHours when I run this code after step 12 :

``````  if (day === "Monday") {
return 8;
} else if (day === "Tuesday") {
return 5;
} else if (day === "Wednesday") {
return 8;
} else if (day === "Thursday") {
return 8;
} else if (day === "Friday") {
return 8;
} else if (day === "Saturday") {
return 8;
} else if (day === "Sunday") {
return 9;
} else {
return "Error";
}
};

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

const getActualSleepHours = () =>
8 + 5 + 8 + 8 + 8 + 8 + 9;

console.log(getActualSleepHours());

const getIdealSleepHours = idealHours => idealHours * 7;

console.log(getIdealSleepHours());

const calculateSleepDebt = () => {
let actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours(8);

if (actualSleepHours === idealSleepHours) {
console.log("You got the perfect amount of sleep!.");
} else if (actualSleepHours > idealSleepHours) {
console.log(
"You got " +
(actualSleepHours - idealSleepHours) +
" hour more sleep than needed!."
);
} else if (actualSleepHours < idealSleepHours) {
console.log(
"You need to get some rest because you've slept " +
(idealSleepHours - actualSleepHours) +
" less this week!."
);
} else {
console.log("Something went wrong!.");
}
};

calculateSleepDebt();

``````

That actually logs 54 when I call it.

You do get NaN for calling getIdealSleepHours without an argument: