-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixedJuices.js
47 lines (36 loc) · 1.01 KB
/
mixedJuices.js
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
const timeToMixJuice = (name) => {
const juices = {
'Pure Strawberry Joy': 0.5,
'Energizer': 1.5,
'Green Garden': 1.5,
'Tropical Island': 3,
'All or Nothing': 5
}
return juices[name] || 2.5;
}
const limesToCut = (wedgesNeeded, limes) => {
let wedges = 0;
let limeSize = {
'small': 6,
'medium': 8,
'large': 10
}
for (let i = 0; i < limes.length; i++) {
wedges += limeSize[limes[i]];
if (wedges >= wedgesNeeded) {
return i + 1;
}
}
return 'not enough limes';
}
const remainingOrders = (timeLeft, orders) => {
let remainingTime = 0;
for (let i = 0; i < orders.length; i++) {
remainingTime += timeToMixJuice(orders[i]);
if (remainingTime > timeLeft) {
return orders.slice(i+1);
}
}
return 'all orders completed';
}
console.log(remainingOrders(5, ['Energizer', 'All or Nothing', 'Green Garden']))