-
Notifications
You must be signed in to change notification settings - Fork 0
/
JS_sleepDebtCalc
56 lines (49 loc) · 1.46 KB
/
JS_sleepDebtCalc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const getSleepHours = day => {
day = day.toLowerCase();
switch (day) {
case 'monday':
return 13
break;
case 'tuesday':
return 8
break;
case 'wednesday':
return 8
break;
case 'thursday':
return 8
break;
case 'friday':
return 8
break;
case 'saturday':
return 8
break;
case 'sunday':
return 8
break;
default:
'Error'
};
}
const getActualSleepHours = () => getSleepHours('Monday') + getSleepHours('tuesday') + getSleepHours('wednesday') + getSleepHours('thursday') + getSleepHours('friday') + getSleepHours('saturday') + getSleepHours('sunday');
const getIdealSleepHours = () => {
let idealHours = 8;
return idealHours * 7;
}
const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours();
if (actualSleepHours === idealSleepHours) {
console.log('You have had the ideal amount of sleep.');
} else if (actualSleepHours > idealSleepHours) {
console.log('You have had too much sleep. You overslept by ' + (actualSleepHours - idealSleepHours) + ' hours.');
} else if (actualSleepHours < idealSleepHours) {
console.log('You haven\'t had enough sleep. You have underslept by ' + (idealSleepHours - actualSleepHours) + ' hours.');
} else {
console.log('Shit\'s fucked yo. Check all the things.')
}
}
console.log(getActualSleepHours());
console.log(getIdealSleepHours());
calculateSleepDebt();