Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created December 29, 2019 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/f337670878e7d917eaf1690274d7a0ff to your computer and use it in GitHub Desktop.
Save codecademydev/f337670878e7d917eaf1690274d7a0ff to your computer and use it in GitHub Desktop.
Codecademy export
const getSleepHours = day =>
day === 'monday' ? 8
: day === 'tuesday' ? 7
: day === 'wednesday' ? 8
: day === 'thursday' ? 9
: day === 'friday' ? 6
: day === 'saturday' ? 7
: day === 'sunday' ? 8
: 'please type any one particular day';
// console.log(getSleepHours('tuesday'));
// console.log(getSleepHours('monday'));
// console.log(getSleepHours('wednesday'));
// console.log(getSleepHours('sunday'));
const getActualSleepHours = () => getSleepHours('monday')+getSleepHours('tuesday')+getSleepHours('wednesday')+getSleepHours('thursday')+getSleepHours('friday')+getSleepHours('saturday')+getSleepHours('sunday');
const getIdealSleepHours = () => {
const idealHours = 8;
return idealHours*7;
}
// console.log(getActualSleepHours());
// console.log(getIdealSleepHours());
const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours();
actualSleepHours === idealSleepHours ? console.log('user got the perfect amount of sleep')
: actualSleepHours > idealSleepHours ? console.log(`user got more sleep of this much ${actualSleepHours-idealSleepHours} hours`) : console.log(`user should get more sleep of this much ${idealSleepHours-actualSleepHours} hours`);
}
console.log(calculateSleepDebt());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment