-
-
Save codecademydev/fbab3deb8ffd26e71018e24e0d14686c 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 => { | |
day = day.toLowerCase(); | |
switch(day){ | |
case 'monday': | |
return 8; | |
case 'tuesday': | |
return 8; | |
case 'wednesday': | |
return 8; | |
case 'thursday': | |
return 8; | |
case 'friday': | |
return 6; | |
case 'saturday': | |
return 6; | |
case 'sunday': | |
return 8; | |
} | |
} | |
const getActualSleepHours = () => { | |
return getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday') | |
} | |
const getIdealSleepHours = (idealHours) =>{ idealHours = 8 | |
return idealHours * 7 | |
} | |
const calculateSleepDebt = () => { | |
actualSleepHours = getActualSleepHours(); | |
idealSleepHours = getIdealSleepHours(); | |
hours = Math.abs(idealSleepHours - actualSleepHours) | |
if (actualSleepHours === idealSleepHours) { | |
console.log( 'You slept hours.'+ hours +'' You are sleeping well') | |
} | |
else if (actualSleepHours <= idealSleepHours) { | |
console.log( 'Your debt is You are not resting enough... Get more sleep') | |
} | |
else { | |
console.log( 'You are sleeping more than necessary') | |
} | |
} | |
console.log(getActualSleepHours()); | |
console.log(getIdealSleepHours()); | |
console.log(calculateSleepDebt()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment