Getting an undefined day at the beginning?


#1

My code works but I get an extra day with "How many hours did you sleep on undefined?" before it asks for Monday, Tuesday, etc.

My code:

function getSleepHours(day) {
var hours = prompt("How many hours did you sleep 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 much sleep is ideal each night?");
return Number(idealHours) * 7;
}

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

if (actualSleepHours === idealSleepHours){
console.log("Getting ideal hours");
}
if (actualSleepHours > idealSleepHours){
console.log("More than enough sleep.");
}
if (actualSleepHours < idealSleepHours) {
console.log('Rest More');
}
}

getSleepHours();
calculateSleepDebt();

Thank you!!


#2

What if this call were to calculateSleepDebt(), only, skipping that line?