Sleep Debt Calculator


function getSleepHours(day){
var hours = prompt('How many hours of sleep did you get on ' + day + '?');
return hours;

function getActualSleepHours(day){

return getSleepHours('Monday') + getSleepHours('Tuesday') + getSleepHours('Wednesday')+getSleepHours('Thursday') + getSleepHours('Friday') + getSleepHours('Saturday') + getSleepHours('Sunday');


function getIdealSleepHours(){
var idealHours = prompt('How many hours of sleep is ideal per night?');
return Number(idealHours) * 7;

function calculateSleepDebt() {
var actualSleepHours = getActualSleepHours();
var idealSleepHours = getIdealSleepHours();

if(actualSleepHours === idealSleepHours){
console.log('You got the perfect amount of sleep');
else if(actualSleepHours > idealSleepHours){
console.log('You got '+(actualHoursPerWeek-idealHoursPerWeek)+ 'more sleep than needed');
else {
console.log('You should get '+(idealHoursPerWeek-actualHoursPerWeek)+'more hours of sleep.');


if (actualSleepHours < idealSleepHours) {
console.log('You got '+(idealSleepHours-actualSleepHours)+'hours less sleep this week than you need. Get some rest.');
else if (actualSleepHours > idealSleepHours) {
console.log('You got '+(actualSleepHours-idealSleepHours)+'hours more than you need this week.');

Hi, who could tell what's wrong with my code?


Did you mean to write,

return Number(hours);



interesting piece of advice but it didn't help (I tried all possible combinations and refactored it back and forth)
maybe you could re-write it so codecademy accepted it. I know that its a big code but still...
why there is no guidance for projects and only for the lessons. zero info how to correct projects.


That was just the first thing I saw that didn't look right. Haven't even begun to analyze your code since I had to do the project to come up with a comparative model. I've got a working model, so will look at this next chance I get.



To get the total sleep hours that the user actually slept,
declare a new function named getActualSleepHours that takes
no parameters.

Does your function have a parameter?


From my understanding of the code, your lines 4 and 5 can be combined to simply read on line 4:
return Number(hours);

this is just a small comparison of your code to mine, and im stil hitting errors when running the JS on an external site .