Fix #299
This commit is contained in:
@ -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.
|
Use `Array.filter()` to create a new array that contains every nth element of a given array.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === 0);
|
const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);
|
||||||
// everyNth([1,2,3,4,5,6], 2) -> [ 1, 3, 5 ]
|
// everyNth([1,2,3,4,5,6], 2) -> [ 2, 4, 6 ]
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user