From 39d99a4723116c319902629d5604d551f71358a1 Mon Sep 17 00:00:00 2001 From: Brian Douglas Date: Tue, 5 Jun 2018 13:25:49 +0100 Subject: [PATCH] Update `countOccurrences` function Removes unnecessary addition of `0`. --- snippets/countOccurrences.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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