We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dedf7b0 commit 12fe974Copy full SHA for 12fe974
set-operations.js
@@ -0,0 +1,17 @@
1
+const intersect = (a, b) => {
2
+ return a.filter(element => b.indexOf(element) !== -1);
3
+};
4
+
5
+const difference = (a, b) => {
6
+ return a.filter(element => b.indexOf(element) === -1);
7
8
9
+const union = (a, b) => {
10
+ const intersection = intersect(a, b);
11
+ return difference(a, intersection).concat(b);
12
13
14
+const symmetricDifference = (a, b) => {
15
16
+ return difference(a.concat(b), intersection);
17
0 commit comments