Update snippet descriptions
This commit is contained in:
@ -5,11 +5,15 @@ tags: array,math,intermediate
|
||||
|
||||
Returns the unique symmetric difference between two arrays, not containing duplicate values from either array.
|
||||
|
||||
- Use `Array.prototype.filter()` and `Array.prototype.includes()` on each array to remove values contained in the other, then create a `Set` from the results, removing duplicate values.
|
||||
- Use `Array.prototype.filter()` and `Array.prototype.includes()` on each array to remove values contained in the other.
|
||||
- Create a `new Set()` from the results, removing duplicate values.
|
||||
|
||||
```js
|
||||
const uniqueSymmetricDifference = (a, b) => [
|
||||
...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))])
|
||||
...new Set([
|
||||
...a.filter(v => !b.includes(v)),
|
||||
...b.filter(v => !a.includes(v)),
|
||||
]),
|
||||
];
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user