From afe42af21cb724e13678bc9be6cfbe3cd8848490 Mon Sep 17 00:00:00 2001 From: Y_Less Date: Thu, 21 Dec 2017 18:19:39 +0000 Subject: [PATCH] Fix #299 --- snippets/everyNth.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/everyNth.md b/snippets/everyNth.md index 0c79e3a1f..f326ebe2b 100644 --- a/snippets/everyNth.md +++ b/snippets/everyNth.md @@ -5,6 +5,6 @@ Returns every nth element in an array. Use `Array.filter()` to create a new array that contains every nth element of a given array. ```js -const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === 0); -// everyNth([1,2,3,4,5,6], 2) -> [ 1, 3, 5 ] +const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); +// everyNth([1,2,3,4,5,6], 2) -> [ 2, 4, 6 ] ```