Merge pull request #679 from BrianDGLS/patch-5

Update `countOccurrences` function
This commit is contained in:
Angelos Chalaris
2018-06-05 18:09:32 +03:00
committed by GitHub

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