Created
October 21, 2017 19:13
-
-
Save khayyamsaleem/9d30bafca8f536b994008bacde29e1ca to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
break; | |
case "Tuesday": | |
return 6 | |
break; | |
case "Wednesday": | |
return 5 | |
break; | |
case "Thursday": | |
return 7 | |
break; | |
case "Friday": | |
return 8 | |
break; | |
case "Saturday": | |
return 9 | |
break; | |
case "Sunday": | |
return 7 | |
default: | |
console.log('you did not sleep a wink') | |
break; | |
} | |
}; | |
const getActualSleepHours = ()=> { | |
return getSleepHours('Monday') + | |
getSleepHours('Tuesday') + | |
getSleepHours('Wednesday') + | |
getSleepHours('Thursday') + | |
getSleepHours('Friday') + | |
getSleepHours('Saturday') + | |
getSleepHours('Sunday'); | |
}; | |
const getIdealSleepHours = () => { | |
let idealHours = 8; | |
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 ' + (actualSleepHours - idealSleepHours) + 'more sleep than neccessary'); | |
} | |
if (actualSleepHours < idealSleepHours) | |
{ | |
console.log('You got ' + (idealSleepHours - actualSleepHours) + ' hours 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