-
-
Save codecademydev/ede8145082951f7d05b1abdfc0a85d3b 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 => { | |
switch(day){ | |
case 'Monday': | |
return 8; | |
case'Tuesday': | |
return 8; | |
case'Wednesday': | |
return 8; | |
case'Thursday': | |
return 4; | |
case'Friday': | |
return 6; | |
case'Saturday': | |
return 7; | |
case'Sunday': | |
return 6; | |
} | |
const getActualSleepHours = () => /* 8+8+8+4+6+7+6; | |
const getIdeaSleepHours=idealHours => idealHours* 7; */ | |
getSleepHours('Monday') + | |
getSleepHours('Tuesday') + | |
getSleepHours('Wednasday') + | |
getSleepHours('Thursday') + | |
getSleepHours('Friday') + | |
getSleepHours('Saturday') + | |
getSleepHours('Sunday') + | |
console.log(getSleepHours('Friday')); | |
} | |
const getIdealSleepHours = () => { | |
const idealHours =8; | |
return idealHours * 7; | |
console.log(getActualSleepHours()); | |
console.log(getIdealSleepHours()); | |
}; | |
const calculateSleepDebt = () =>{ | |
const actualSleepHours= getActualSleepHours(); | |
const idealSleepHours = getIdealSleepHours(); | |
if (actualSleepHours===idealSleepHours){ | |
console.log('You got the perfect amount of sleep ' + 'You dont have dept of sleep'); | |
} else if(actualSleepHours>idealSleepHours) { | |
console.log('You got ' + (idealSeepHours - actualSleepHours) + ' hour(s) more sleep than needed'); | |
} else { | |
console.log('You got ' + (idealSeepHours - actualSleepHours) + 'hour(s) less sleep than you need You should get some rest'); | |
} | |
} | |
calculateSleepDebt(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment