Skip to content

Commit

Permalink
Use Boolean for compact
Browse files Browse the repository at this point in the history
  • Loading branch information
AvraamMavridis authored Dec 17, 2017
1 parent 80cd011 commit 8b0be61
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion snippets/compact.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
Use `Array.filter()` to filter out falsey values (`false`, `null`, `0`, `""`, `undefined`, and `NaN`).

```js
const compact = (arr) => arr.filter(v => v);
const compact = (arr) => arr.filter(Boolean);
// compact([0, 1, false, 2, '', 3, 'a', 'e'*23, NaN, 's', 34]) -> [ 1, 2, 3, 'a', 's', 34 ]
```

0 comments on commit 8b0be61

Please sign in to comment.