Created
November 6, 2020 21:59
-
-
Save sentientmonkey/d7177bb1e61d9426dfea9b46362c057a to your computer and use it in GitHub Desktop.
This file contains 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* eachSlice(array, size) { | |
for(let current=0; current < array.length; current+=size) { | |
yield array.slice(current, current+size); | |
} | |
} | |
const slice = eachSlice([1,2,3,4,5], 2); | |
for (let value of slice) { | |
console.log(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment