Created
September 2, 2021 12:07
-
-
Save rostegg/bc9abd989c3f6753cd835e238c32513e to your computer and use it in GitHub Desktop.
Group elemnts of array, skiping last N elements in group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function groupSkip(arr, shift, skip = 1) { | |
const res = [] | |
let limit = 0 | |
while (limit+shift <= arr.length) { | |
res.push(arr.slice(limit, shift + limit - skip)) | |
limit += shift | |
} | |
return res | |
} | |
const res = groupSkip(array, 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment