Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 18, 2019 23:18
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/5a536a243f8e1d556281985aca8f1e4b to your computer and use it in GitHub Desktop.
Save codecademydev/5a536a243f8e1d556281985aca8f1e4b to your computer and use it in GitHub Desktop.
Codecademy export
const getSleepHours = day => {
if (day === 'monday') {
return 8;
}
else if (day === 'tuesday') {
return 7;
}
else if (day === 'wednesday') {
return 9;
}
else if (day === 'thursday') {
return 8;
}
else if (day === 'friday') {
return 8;
}
else if (day === 'saturday') {
return 7;
}
else if (day === 'sunday') {
return 10;
}
};
const getActualSleepHours = () => getSleepHours('monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday');
const getIdealSleepHours = () => {
const idealHours = 8;
return idealHours * 7;
}
const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours();
if (actualSleepHours == idealSleepHours) {
console.log('perfect amount');
}
else if (actualSleepHours > idealSleepHours) {
console.log((actualSleepHours - idealSleepHours) + ' hours too much sleep');
}
else if (actualSleepHours < idealSleepHours) {
console.log((idealSleepHours - actualSleepHours) +' hours in sleep debt! get some rest!');
}
};
console.log(calculateSleepDebt());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment