Check out this code snippet that demonstrates how to divide an array into chunks. If you have a more efficient solution, please share it with me.
var numbers = [];
for (var i = 0; i < 4500; i++) {
numbers.push(i);
}
var chunks = {};
var start = 0;
var end = 999;
if (numbers.length > 999) {
for (var i = 0; i < 4; i++) {
chunks[i] = numbers.slice(start, end);
start = end + 1;
end = start + 999;
console.log(start + ":" + end);
}
}
console.log(numbers.length);
console.log(chunks[1].length);