Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 23, 2020 10:03
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/fab22afbe13d4305a4f9d9f83a2e52e0 to your computer and use it in GitHub Desktop.
Save codecademydev/fab22afbe13d4305a4f9d9f83a2e52e0 to your computer and use it in GitHub Desktop.
Codecademy export
const getSleepHours = (day) => {
if (day === 'Monday') {
return 5;
} else if (day === 'Tuesday') {
return 5;
} else if (day === 'Wednesday') {
return 5;
} else if (day === 'Thursday') {
return 5;
} else if (day === 'Friday') {
return 5;
} else if (day === 'Saturday') {
return 5;
} else if (day === 'Sunday') {
return 5;
}
}
const getActualSleepHours = () =>{
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 had the perfect amount of sleep!');
} else if (actualSleepHours > idealSleepHours) {
console.log('You got ' + (actualSleepHours - idealSleepHours) + 'hours more sleep than you needed!');
} else if (actualSleepHours < idealSleepHours) {
console.log('You got ' + (idealSleepHours - actualSleepHours) + 'hours less sleep than you needed. Get some rest!');
}
}
calculateSleepDebt();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment