Update snippet descriptions

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-22 20:24:44 +03:00
parent 5cb69e3c5c
commit aa425812b4
40 changed files with 151 additions and 87 deletions

View File

@ -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)),
]),
];
```