-
-
Save codecademydev/96fb4be1a837cc84b0adf7dcbe6dfcf3 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
day=('Sunday'||'Monday'||'Tuesday'||'Wednesday'||'Thursday'||'Friday'||'Saturday'); | |
function getSleepHours(day) { | |
var hours=prompt('How many hours of sleep did you get on '+ day + '?'); | |
return(hours); | |
Number(hours); | |
} | |
function getActualSleepHours() { | |
return getSleepHours('Sunday') + | |
getSleepHours('Monday') + | |
getSleepHours('Tuesday') + | |
getSleepHours('Wednesday') + | |
getSleepHours('Thursday') + | |
getSleepHours('Friday') + | |
getSleepHours('Saturday'); | |
} | |
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.'); | |
} | |
actualHoursPerWeek=getSleepHours(day); | |
idealHoursPerWeek=getIdealSleepHours(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I changed the last part to the following:
actualHoursPerWeek=getSleepHours(day);
console.log(actualHoursPerWeek);
idealHoursPerWeek=getIdealSleepHours();
console.log(idealHoursPerWeek);
However when the prompt comes up to ask for actual sleep per day I can only input for one day instead of all 7. How do I make it so I can input all 7 days?