We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d1c9fff commit b83a89aCopy full SHA for b83a89a
1 file changed
src/grap3fruit/js/goorm/42578_2.js
@@ -0,0 +1,29 @@
1
+function solution(clothes) {
2
+ let answer = 1;
3
+ console.log(clothes);
4
+
5
+ const map = new Map();
6
7
+ clothes.forEach((cloth) => {
8
+ if (!map.get(cloth[1])) {
9
+ return map.set(cloth[1], [cloth[0]]);
10
+ }
11
12
+ map.get(cloth[1]).push(cloth[0]);
13
+ });
14
15
+ for (let key of map.keys()) {
16
+ answer *= map.get(key).length + 1;
17
18
+ answer -= 1;
19
20
+ return answer;
21
+}
22
23
+const clothes = [
24
+ ['yellow_hat', 'headgear'],
25
+ ['blue_sunglasses', 'eyewear'],
26
+ ['green_turban', 'headgear'],
27
+];
28
29
+console.log(solution(clothes));
0 commit comments