The union method does not remove duplicates from the first array in arrays as the challenge requires: "If there are duplicate elements, only add it once to the new array".
Here, the expected result would be [1, 2, 3], but is [1, 1, 2, 3]
const result = union([[1, 1, 2], [2, 3]]);
console.log(result);
The
unionmethod does not remove duplicates from the first array inarraysas the challenge requires: "If there are duplicate elements, only add it once to the new array".Here, the expected result would be
[1, 2, 3], but is[1, 1, 2, 3]