Format snippets

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-22 20:23:47 +03:00
parent 3936a1d3b8
commit aedcded750
70 changed files with 185 additions and 101 deletions

View File

@ -3,12 +3,13 @@ title: filterNonUnique
tags: array,beginner
---
Returns an array with the non-unique values filtered out.
Creates an array with the non-unique values filtered out.
- Use `Array.prototype.filter()` to create an array containing only the unique values.
```js
const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
const filterNonUnique = arr =>
arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
```
```js