-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkata.js
67 lines (65 loc) · 1.26 KB
/
kata.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const boredomScore = {
accounts: 1,
finance: 2,
canteen: 10,
regulation: 3,
trading: 6,
change: 6,
IS: 8,
retail: 5,
cleaning: 4,
'pissing about': 25,
};
function boredom(staff) {
let a = ['kill me now', 'i can handle this', 'party time!!'];
let score = Object.values(staff).reduce((acc, i) => acc + boredomScore[i], 0);
return score <= 80 ? a[0] : (score < 100) & (score > 80) ? a[1] : a[2];
}
console.log(
boredom({
tim: 'change',
jim: 'accounts',
randy: 'canteen',
sandy: 'change',
andy: 'change',
katie: 'IS',
laura: 'change',
saajid: 'IS',
alex: 'trading',
john: 'accounts',
mr: 'finance',
})
);
// 'kill me now'
console.log(
boredom({
tim: 'IS',
jim: 'finance',
randy: 'pissing about',
sandy: 'cleaning',
andy: 'cleaning',
katie: 'cleaning',
laura: 'pissing about',
saajid: 'regulation',
alex: 'regulation',
john: 'accounts',
mr: 'canteen',
})
);
// 'i can handle this'
console.log(
boredom({
tim: 'accounts',
jim: 'accounts',
randy: 'pissing about',
sandy: 'finance',
andy: 'change',
katie: 'IS',
laura: 'IS',
saajid: 'canteen',
alex: 'pissing about',
john: 'retail',
mr: 'pissing about',
})
);
// 'party time!!'