Skip to content

Instantly share code, notes, and snippets.

@MortalCatalyst
Created May 28, 2017 03:56
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 MortalCatalyst/41f59d613bf50da6929896fd24c7d8cd to your computer and use it in GitHub Desktop.
Save MortalCatalyst/41f59d613bf50da6929896fd24c7d8cd to your computer and use it in GitHub Desktop.
function getSleepHours(day){
hours = prompt("How long did you sleep on "+ day + "? ");
return Number(hours);
}
function getActualSleepHours() {
Monday = getSleepHours("Monday");
Tuesday = getSleepHours("Tuesday");
Wednesday = getSleepHours("Wednesday");
Thursday = getSleepHours("Thursday");
Friday = getSleepHours("Friday");
Saturday = getSleepHours("Saturday");
Sunday = getSleepHours("Sunday");
Total_Sleep = Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday;
return Total_Sleep;
}
function getIdealSleepHours() {
Sleep = prompt("How much sleep a day do you like? ");
Weeks_Sleep = sleep * 7;
}
function calculateSleepDebt() {
actualSleepHours = getActualSleepHours();
idealSleepHours = getIdealSleepHours();
overUnderHours = actualSleepHours - idealSleepHours;
if (actualSleepHours === idealSleepHours) {
console.log("You got the ideal sleep");
}
else if (actualSleepHours > idealSleepHours) {
console.log("You overslept " + overUnderHours + " hours go for a jog.");
} else {
console.log("You are short " + overUnderHours + " hours sleep need to get some rest.");
}
}
getSleepHours(Monday);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment