Last active
November 5, 2018 11:44
-
-
Save Vincent-gv/2b27c02e183ee9c55263d9cce859a62d to your computer and use it in GitHub Desktop.
Sleep Debt Calculator
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 === 'lundi') {return 8;} | |
if (day === 'mardi') {return 7;} | |
if (day === 'mercredi') {return 6;} | |
if (day === 'jeudi') {return 5;} | |
if (day === 'vendredi') {return 10;} | |
if (day === 'samedi') {return 9;} | |
if (day === 'dimanche') {return 13;} | |
}; | |
const getActualSleepHours = () => | |
getSleepHours('lundi') + getSleepHours('mardi') + getSleepHours('mercredi') + getSleepHours('jeudi') + getSleepHours('vendredi') + getSleepHours('samedi') + getSleepHours('dimanche'); | |
const getIdealSleepHours = () => { | |
const idealHours = 8; | |
return idealHours*7; | |
}; | |
const calculateSleepDebt = () => { | |
const actualSleepHours = getActualSleepHours(); | |
const idealSleepHours = getIdealSleepHours(); | |
if (actualSleepHours===idealSleepHours) {console.log('You\'ve got ' + idealSleepHours + ' hours of sleep. Perfect amount of sleep.')} | |
if (actualSleepHours>idealSleepHours) {console.log('You sleep ' + (actualSleepHours - idealSleepHours) + ' hours more than needed')} | |
if (actualSleepHours<idealSleepHours) { | |
console.log('You got ' + (idealSleepHours - actualSleepHours) + ' hour(s) less sleep than you needed this week. Get some rest.'); | |
} | |
}; | |
calculateSleepDebt(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://youtu.be/48ko-s_ePbc