How to convert a Set to an Array? – JavaScript

When you remove the duplicate numbers from an array with new Set() method, it turns into a set instead of an array like this let duplicates = [1,2,3,4,5,6,2]; // remove the duplicates let noDuplicates = new Set(duplicates); // output Set {1,2,3,4,5,6} Duplicates may...

How to find the Symmetric Difference? – JavaScript

Easy Solution to find the Symmetric Difference: function sym(args) { const elements = Array.from(arguments) .reduce((a,b)=>a.concat(b).filter(e=>a.indexOf(e)==-1||b.indexOf(e)==-1)); return [... new Set(elements)]; } sym([1, 2, 3], [5, 2, 1, 4]); // result...