-
-
Save codecademydev/005459ee2325e91e1d772818ab7bf211 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
function getSleepHours(day) { | |
var hours = prompt('how many hours of sleep you got on' + day + '?'); | |
return Number(hours); | |
} | |
function getActualSleepHours() { | |
return getSleepHours('Sunday') + getSleepHours('Monday') + getSleepHours('Tuesday') + getSleepHours('Wednesday') + getSleepHours('Thursday') + getSleepHours('Friday') + getSleepHours('Saturday'); | |
} | |
function getIdealSleepHours() { | |
var idealHoursPerNight = prompt('How much Sleep is ideal per night?'); | |
return idealHoursPerNight * 7; | |
} | |
function calculateSleepDebt() { | |
var actualSleepHours = getActualSleepHours(); | |
var idealSleepHours = getIdealSleepHours(); | |
if(actualSleepHours === idealSleepHours) { | |
console.log('You got the perfect amount of sleep'); | |
} | |
else if(actualSleepHours > idealSleepHours) { | |
console.log('You Got ' + (actualSleepHours-idealSleepHours) + ' hours more sleep then you needed this week. You must have alot of energy.'); | |
} | |
else { | |
console.log('You Got ' + (idealSleepHours-actualSleepHours) + ' hours less sleep then you needed this week. Get some rest.'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment