add filterFalsy snippet, tags, and tests

This commit is contained in:
Mykolas Krupauskas
2018-10-29 23:19:01 +02:00
parent e6143218e6
commit 0ec5daa0a5
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]
```