const arr = [
{
Type: "LEARNING",
Time: 150,
TimeP: 10.23,
Switches: 3324,
Description: "Unknown Title"
},
{
Type: "LEARNING",
Time: 150,
TimeP: 10.23,
Switches: 3324,
Description: "Unknown Title"
},
{
Type: "LEARNING",
Time: 150,
TimeP: 10.23,
Switches: 3324,
Description: "Unknown Title"
},
{
Type: "LEARNING",
Time: 150,
TimeP: 10.23,
Switches: 3324,
Description: "Unknown Title"
}
]
function chunked(arr, numChunks) {
const chunks = [];
const chunkSize = arr.length / numChunks | 0;
const numLooseItems = arr.length % numChunks;
for (let i = 0, j = 0; j < numChunks; j++) {
chunks.push(arr.slice(i, i += chunkSize + (j < numLooseItems)));
}
return chunks;
}
const [ head, tail ] = chunked(arr, 2);