JSFiddle - React, Tailwind, and code Playground

by Sergei Sokolov

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);

for (let row of arr) {
	const div = document.createElement('div');
  div.innerText = JSON.stringify(row);
  document.body.appendChild(div);
}