Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 16, 2021 01:35
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/fb0624032feb4eb31471517ff9a4569f to your computer and use it in GitHub Desktop.
Save codecademydev/fb0624032feb4eb31471517ff9a4569f to your computer and use it in GitHub Desktop.
Codecademy export
const getSleepHours = day => {
if (day === 'monday') {
return 8;
} else if (day === 'tuesday') {
return 8;
} else if (day === 'wednesday') {
return 8;
} else if (day === 'thursday') {
return 8;
} else if (day === 'friday') {
return 10;
} else if (day === 'saturday') {
return 10;
} else if (day === 'sunday') {
return 8;
}
};
const getActualSleepHours = () =>
getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday');
const getIdealSleepHours = () => {
const idealHours = 9;
return idealHours * 7;
};
const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours();
};
if (actualSleepHours === idealSleepHours) {
console.log('Congrats, you know how to sleep.');
} else if (actualSleepHours > idealSleepHours) {
console.log('User got more sleep than needed');
} else {
console.log('User should probably get some rest')
};
if (actualSleepHours < idealSleepHours) {
console.log('You got ' (idealSleepHours - actualSleepHours) + 'hours less than you needed this week. Get some sleep!');
}
calculateSleepDebt();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment