-
-
Save codecademydev/08230a4dfbcc4ffc7a55b26d47ddb4ee 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 did you get on '+ day + '?'); | |
return(Number(hours)); | |
} | |
function getActualSleepHours() { | |
var total = (getSleepHours('Sunday') + | |
getSleepHours('Monday') + | |
getSleepHours('Tuesday') + | |
getSleepHours('Wednesday') + | |
getSleepHours('Thursday') + | |
getSleepHours('Friday') + | |
getSleepHours('Saturday')); | |
return total; | |
} | |
function getIdealSleepHours() { | |
var idealHours = prompt('How many hours of sleep per night is ideal?'); | |
return Number(idealHours) * 7; | |
} | |
function calculatesSleepDebt() { | |
var actualSleepHours=getActualSleepHours(); | |
var idealSleepHours=getIdealSleepHours(); | |
if (idealSleepHours === actualSleepHours) { | |
console.log('You got the perfect amount of sleep.'); | |
} else if (idealSleepHours < actualSleepHours) { | |
console.log('You got too much sleep.'); | |
} else { | |
console.log('You need to get more sleep.'); | |
} | |
console.log(' Compared to your ideal number of ' + idealSleepHours + ' sleep hours you got ' + (actualSleepHours-idealSleepHours) + ' hours of sleep.'); | |
} | |
console.log(calculatesSleepDebt()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment