JSFiddle - React, Tailwind, and code Playground

by TheCrossCarrier

JavaScript

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) => {
  if (index == 0) {
  
  // в зависимости от индекса
    //получить тут 0
    // 6
    //12 
  }


  // в зависимости от индекса
})