diff --git a/snippets/aperture.md b/snippets/aperture.md index 3078cca9b..d948d8184 100644 --- a/snippets/aperture.md +++ b/snippets/aperture.md @@ -12,11 +12,11 @@ If `n` is greater than the length of `arr`, return an empty array. const aperture = (n, arr) => n > arr.length ? [] - : arr.slice(n - 1).map((v, i) => [...arr.slice(i, i + n - 1), v]); + : arr.slice(n - 1).map((v, i) => arr.slice(i, i + n)); ``` ```js -R.aperture(2, [1, 2, 3, 4]); // [[1, 2], [2, 3], [3, 4]] -R.aperture(3, [1, 2, 3, 4]); // [[1, 2, 3], [2, 3, 4]] -R.aperture(5, [1, 2, 3, 4]); // [] +aperture(2, [1, 2, 3, 4]); // [[1, 2], [2, 3], [3, 4]] +aperture(3, [1, 2, 3, 4]); // [[1, 2, 3], [2, 3, 4]] +aperture(5, [1, 2, 3, 4]); // [] ```