Update intersection.md
This commit is contained in:
@ -10,7 +10,7 @@ Create a `Set` from `b`, then use `Array.prototype.filter()` on `a` to only keep
|
||||
```js
|
||||
const intersection = (a, b) => {
|
||||
const s = new Set(b);
|
||||
return a.filter(x => s.has(x));
|
||||
return [...new Set(a)].filter(x => s.has(x));
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user