const chunks = (arr, chunkSize) =>
arr.reduce((acc, n, i) => (
(i % chunkSize) || acc.push([]),
acc[acc.length - 1].push(n),
acc
), []);
const data = [...Array(12).keys()];
const chunkSize = 2;
const html = chunks(data, chunkSize)
.map(n => `<div>${n.map(m => `<div>${m}</div>`).join('')}</div>`)
.join('');
doublediv = []
arr = [0,1,2,3,4,5,6,7,8,9,10,11,12]
for (let i = 0; i < arr.length; i++) {
if(doublediv.length < 2) {
doublediv.push(arr[i])
} else {
console.log(doublediv)
console.log('extra div')
doublediv = [arr[i]]
}
}