const chunk = (a, n) => [...Array(Math.ceil(a.length / n))].map((_, i) => a.slice(n * i, n + n * i));
let arr = chunk([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 6);
console.log(arr);
// сейчас имеем
//0: [0, 1, 2, 3, 4, 5]
//1: [6, 7, 8, 9, 10, 11]
//2: [12]
arr.forEach((item, index) {
//получить тут отдельно [0, 1, 2, 3, 4, 5]
// отдельно[6, 7, 8, 9, 10, 11]
//отдельно [12]
}
})
const chunk = (a, n) => [...Array(Math.ceil(a.length / n))].map((_, i) => a.slice(n * i, n + n * i));
let arr2 = chunk([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 6);
console.log(arr2);
arr2.forEach(item => console.log(item[0]));