SHARE
TWEET

Untitled

a guest Oct 17th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. getSleepHours = day => {
  2.   switch (day) {
  3.     case 'Monday':
  4.       return 8;
  5.       break;
  6.     case 'Tuesday':
  7.       return 7;
  8.       break;
  9.     case 'Wednesday':
  10.       return 6;
  11.       break;
  12.     case 'Thrusday':
  13.       return 5;
  14.       break;
  15.     case 'Friday':
  16.       return 4;
  17.       break;
  18.     case 'Saturday':
  19.       return 3;
  20.       break;
  21.     case 'Sunday':
  22.       return 2;
  23.       break;
  24.   }
  25. }
  26.  
  27. getActualSleepHours = () => getSleepHours('Monday') + getSleepHours('Tuesday') + getSleepHours('Wednesday') + getSleepHours('Thrusday') + getSleepHours('Friday') + getSleepHours('Saturday') + getSleepHours('Sunday');
  28.  
  29. getIdealSleepHours = (idealHours) => {
  30.     return idealHours * 7;
  31.    }
  32.                            
  33. calculateSleepDebt = () => {
  34.   const actualSleepHours = getActualSleepHours();
  35.   const idealSleepHours = getIdealSleepHours(5);
  36.  
  37.   if (actualSleepHours === idealSleepHours) {
  38.     return 'You are getting the perfect amount of sleep.';
  39.   } else if (actualSleepHours > idealSleepHours) {
  40.     return 'You are getting more sleep than needed. You can sleep ' + (actualSleepHours - idealSleepHours) + ' hours less.';    
  41.   } return 'You should get some rest. You need to sleep more ' + (idealSleepHours - actualSleepHours) + ' hours per week.'
  42. }
  43.  
  44. console.log(calculateSleepDebt());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top