This my code:
function getSleepHours(day){
day = day.toLowerCase()
switch (day){
case 'monday':
return 4;
break;
case 'tuesday':
return 7;
break;
case 'wednesday':
return 8;
break;
case 'thursday':
return 3;
break;
case 'friday':
return 9;
break;
case 'saturday':
return 5;
break;
case 'sunday':
return 5;
break;
}
}
const getActualSleepHours = () => getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday')
const getIdealSleepHours = () => {
let idealHours = 5
return idealHours * 7
}
function calculateSleepDebt(){
let actualSleepHours = getActualSleepHours
let idealSleepHours = getIdealSleepHours
if (actualSleepHours === idealSleepHours){
console.log('Perfect amount of sleep achieved!')
console.log(`You got the same hours of sleep as your ideal hours.`)
return `Your target was ${idealSleepHours} of sleep.`
} else if (actualSleepHours > idealSleepHours){
console.log('You got more than your ideal needed sleep hours!')
console.log(`You got ` + (actualSleepHours - idealSleepHours) ` more hours than your ideal`)
} else if (actualSleepHours < idealSleepHours){
console.log('You got less than the your ideal sleep hours!')
console.log('You got ' + (idealSleepHours - actualSleepHours) + ' less hours than your ideal sleep hours')
}
}
console.log(calculateSleepDebt())
Confused as to why it isn’t working. I understand that the end is messy but It should at least execute the right if then statement but its not. help!