File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ const union = (set1, set2) => {
3535} ;
3636console . log ( union ( setA , setB ) ) ;
3737
38+ console . log ( new Set ( [ ...setA , ...setB ] ) ) ;
39+
3840// --------- Intersection ----------
3941const intersection = ( set1 , set2 ) => {
4042 const intersectionSet = new Set ( ) ;
@@ -47,6 +49,8 @@ const intersection = (set1, set2) => {
4749} ;
4850console . log ( intersection ( setA , setB ) ) ;
4951
52+ console . log ( new Set ( [ ...setA ] . filter ( x => setB . has ( x ) ) ) ) ;
53+
5054// alternative - works on FF only
5155// console.log(new Set([x for (x of setA) if (setB.has(x))]));
5256
@@ -62,5 +66,7 @@ const difference = (set1, set2) => {
6266} ;
6367console . log ( difference ( setA , setB ) ) ;
6468
69+ console . log ( new Set ( [ ...setA ] . filter ( x => ! setB . has ( x ) ) ) ) ;
70+
6571// alternative - works on FF only
6672// console.log(new Set([x for (x of setA) if (!setB.has(x))]));
You can’t perform that action at this time.
0 commit comments