Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 9, 2017 15:21
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/96fb4be1a837cc84b0adf7dcbe6dfcf3 to your computer and use it in GitHub Desktop.
Save codecademydev/96fb4be1a837cc84b0adf7dcbe6dfcf3 to your computer and use it in GitHub Desktop.
Codecademy export
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();
@Brandon-Sellers
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment