Merge pull request #865 from MKrupauskas/master

add filterFalsy snippet, tags, and tests
This commit is contained in:
Angelos Chalaris
2018-12-07 18:15:49 +02:00
committed by GitHub
3 changed files with 32 additions and 0 deletions

13
snippets/filterFalsy.md Executable file
View File

@ -0,0 +1,13 @@
### filterFalsy
Filters out the falsy values in an array.
Use `Array.prototype.filter()` to get an array containing only truthy values.
```js
const filterFalsy = arr => arr.filter(Boolean);
```
```js
filterFalsy(['', true, {}, false, 'sample', 1, 0]); // [true, {}, 'sample', 1]
```