-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkata.js
40 lines (27 loc) · 844 Bytes
/
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
// Like, Dislike, Nothing come from Preloaded
let Dislike = 'Dislike',
Like = 'Like',
Nothing = 'Nothing';
function likeOrDislike(buttons) {
return buttons.reduce((prev, cur) => cur == prev ? Nothing : cur, Nothing)
}
console.log(likeOrDislike([Dislike]));
// Dislike
console.log(likeOrDislike([Like, Like]));
// Nothing
console.log(likeOrDislike([Dislike, Like]));
// Like
console.log(likeOrDislike([Like, Dislike, Dislike]));
// Nothing
console.log(likeOrDislike([Dislike, Dislike]));
// Nothing
console.log(likeOrDislike([Like, Like, Like]));
// Like
console.log(likeOrDislike([Like, Dislike]));
// Dislike
console.log(likeOrDislike([Dislike, Like, Dislike]));
// Dislike
console.log(likeOrDislike([Like, Like, Dislike, Like, Like, Like, Like, Dislike]));
// Dislike
console.log(likeOrDislike([]));
// Nothing