-
-
Save codecademydev/741ebeca300d42a185aab2c72d35e9fd to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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