# Help w/ Sleep Debt Calculator Exercise - I Keep Getting Same Results

#1

I followed the instructions in the exercise to a ‘T’ and the code is not returning any errors, but I would like to be able to return different results.

function getSleepHours(day) {
switch (day) {
case ‘monday’:
return 8;
case ‘tuesday’:
return 6;
case ‘wednesday’:
return 8;
case ‘thursday’:
return 4;
case ‘friday’:
return 9;
case ‘saturday’:
return 10;
case ‘sunday’:
return 6;
}
}

function getActualSleepHours() {
return getSleepHours(‘monday’) + getSleepHours(‘tuesday’) + getSleepHours(‘wednesday’) + getSleepHours(‘thursday’) + getSleepHours(‘friday’) + getSleepHours(‘saturday’) + getSleepHours(‘sunday’);
}

function getIdealSleepHours() {
var idealHours = 8;
return 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 ’ + (actualSleepHours - idealSleepHours) + ‘hours more sleep than you needed!’);
} else {
console.log(‘You only got ’ + (idealSleepHours - actualSleepHours) + ’ hours of sleep. Go get some rest, champ.’);
}

}

calculateSleepDebt();

#2

Park the switch (comment it out) and write a prompt statement to get user input for all seven days, then return it.

``````function getSleepHours(day) {
return Number(prompt(`Hours of sleep on \${day}`, 8));
}
``````