diff --git a/snippets/countOccurrences.md b/snippets/countOccurrences.md index b6e0d2aad..9bef0f1c4 100644 --- a/snippets/countOccurrences.md +++ b/snippets/countOccurrences.md @@ -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