Created
January 21, 2019 20:46
-
-
Save manishprajapatidev/3c47bf992e3f2af306a4cd0bab01bfdc to your computer and use it in GitHub Desktop.
All Array Object into n Group
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 createChunked(arr, chunkSize) { | |
var onjects = [], | |
i = 0, | |
lmt = chunkSize; | |
for (; i < arr.length; i += chunkSize) { | |
if (lmt == (chunkSize * 8)) { | |
lmt = lmt + arr.length - (chunkSize * 8); | |
} | |
if (lmt <= arr.length) { | |
var tmpArray = arr.slice(i, lmt); | |
onjects.push(tmpArray); | |
lmt = lmt + chunkSize; | |
} | |
} | |
return onjects; | |
} | |
var totalObj = allObjects.length; | |
var count = parseInt(totalObj / 8); // n=8 | |
var grouped = createChunked(allObjects, count); | |
console.log(grouped); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment