Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created December 19, 2019 21: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/741ebeca300d42a185aab2c72d35e9fd to your computer and use it in GitHub Desktop.
Save codecademydev/741ebeca300d42a185aab2c72d35e9fd to your computer and use it in GitHub Desktop.
Codecademy export
const getSleepHours = day => {
if (day === 'monday') {
return 8;
} else if (day === 'tuesday') {
return 4;
} else if (day === 'wednesday') {
return 6;
} else if (day === 'thursday') {
return 6;
} else if (day === 'friday') {
return 5;
} else if (day === 'saturday') {
return 7;
} else if (day === 'sunday') {
return 9;
} else {
return 'Error!'
}
};
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());
if (actualSleepHours === idealSleepHours) {
console.log('Perfect amount of sleep. Congrats!');
} else if (actualSleepHours > idealSleepHours) {
console.log('Whoa! Nice Job! Keep it up!');
} else if (actualSleepHours < idealSleepHours) {
console.log('You got ' + (idealSleepHours - actualSleepHours) + 'hours(s) less then needed. Looks like you need more sleep. Try a warm glass of milk.');
} else {
console.log('Error! Check the code!')
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment