-
-
Save codecademydev/9dad25e5135a98ef245640c9f5cfa73c to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getSleepHours = day => { | |
if (day === 'monday') { | |
return 6; | |
} | |
else if (day === 'tuesday') { | |
return 6; | |
} | |
else if (day === 'wednesday') { | |
return 5; | |
} | |
else if (day === 'thursday') { | |
return 6; | |
} | |
else if (day === 'friday') { | |
return 7; | |
} | |
else if (day === 'saturday') { | |
return 8; | |
} | |
else if (day === 'sunday') { | |
return 8; | |
} | |
}; | |
const getActualSleepHours = () => { | |
getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday'); | |
return getSleepHours; | |
}; | |
const getIdealSleepHours = () => { | |
let idealHours = 7; | |
return idealHours * 7; | |
}; | |
const calculateSleepDebt = () => { | |
let actualSleepHours = getActualSleepHours(); | |
let idealSleepHours = getIdealSleepHours(); | |
if (actualSleepHours === idealSleepHours) { | |
console.log('You got the perfect amount of sleep.'); | |
} | |
if (actualSleepHours > idealSleepHours) { | |
console.log('You got too much sleep'); | |
} | |
if (actualSleepHours < idealSleepHours) { | |
console.log('You should get some rest'); | |
} | |
}; | |
calculateSleepDebt(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment