回答編集履歴
1
ちょうせい
test
CHANGED
@@ -19,3 +19,23 @@
|
|
19
19
|
console.log(onlyB) // [4,5]
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
# 調整
|
24
|
+
|
25
|
+
命題にあわせます
|
26
|
+
|
27
|
+
```javacript
|
28
|
+
|
29
|
+
const getUnique=(a,b)=>[a.filter(x=>b.indexOf(x)<0),b.filter(x=>a.indexOf(x)<0)];
|
30
|
+
|
31
|
+
const a = [0,1,2,3];
|
32
|
+
|
33
|
+
const b = [2,3,4,5];
|
34
|
+
|
35
|
+
const [onlyA,onlyB]=getUnique(a,b);
|
36
|
+
|
37
|
+
console.log(onlyA) // [0,1]
|
38
|
+
|
39
|
+
console.log(onlyB) // [4,5]
|
40
|
+
|
41
|
+
```
|