Update countOccurrences function

Removes unnecessary addition of `0`.
This commit is contained in:
Brian Douglas
2018-06-05 13:25:49 +01:00
committed by GitHub
parent 47a89ee80c
commit 11b4eadc38

View File

@ -5,7 +5,7 @@ Counts the occurrences of a value in an array.
Use `Array.reduce()` to increment a counter each time you encounter the specific value inside the array.
```js
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0);
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
```
```js