-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsleepDebtCalculator.js
More file actions
49 lines (44 loc) · 1.26 KB
/
sleepDebtCalculator.js
File metadata and controls
49 lines (44 loc) · 1.26 KB
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
const getSleepHours =(day)=>{
switch(day) {
case "Monday":
return 8
break;
case "Tuesday":
return 6
break;
case "Wednesday":
return 5
break;
case "Thursday":
return 7
break;
case "Friday":
return 6
break;
case "Saturday":
return 9
break;
case "Sunday":
return 5
break;
default:
return "What do you mean? "
}
}
const getActualSleepHours = () =>
8+6+5+7+6+9+15
const getIdealSleepHours = idealHours=>
idealHours * 7;
const calculateSleepDebt = () => {
const actualSleepHours = getActualSleepHours();
const idealSleepHours = getIdealSleepHours(8);
if (actualSleepHours === idealSleepHours){
return console.log("You got the perfect amount of sleep");
} if (actualSleepHours > idealSleepHours){
console.log("You got more sleep than needed");
} else {
console.log("You got " + (idealSleepHours- actualSleepHours) + "hour(S) less sleep than you needed this week . Get some rest");
}
}
calculateSleepDebt()
//Variables that contain arrays can be declared with let or const. Even when declared with const, arrays are still mutable. However, a variable declared with const cannot be reassigned.