SleepDebtCalculator.js error - code does not run!


#1

I've worked my way through the SleepDebtCalculator.js tutorial, but the final code doesn't run. I'm sure it's something simple, but I can't spot it. I would appreciate any advice...

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

function getActualSleepHours(){
return getSleepHours('Monday') +
getSleepHours('Tuesday') +
getSleepHours('Wednesday') +
getSleepHours('Thursday') +
getSleepHours('Friday') +
getSleepHours('Saturday') +
getSleepHours('Sunday');
}

function getIdealSleepHours() {
var idealHours = prompt ('How many hours would you like per night?');
return Number(idealHours) * 7;
}

function calculateSleepDebt() {
var actualSleepHours = getActualSleepHours();
var idealSleepHours = getIdealSleepHours();
if (idealSleepHours === actualSleepHours){
console.log('You got ' + actualSleepHours + 'hour seelp. Perfect sleeping!');
}
else if (idealSleepHours < actualSleepHours){
console.log( 'You got ' +(actualSleepHours - idealSleepHours)+ 'hours sleep. You don\'t need that much sleep!');
}
else {
console.log('You got ' +(actualSleepHours - idealSleepHours)+ 'Get more sleep!');
}
}


#2

you didn't call your calculateSleepDebt() function.you have to call it to make it any use :slight_smile: