let i, j, chunkedArray = [], chunk = 4; let posts = [1,4,5,7,9,12,14,16,23,26,37,48,21,52,43,25]; for (i=0, j=0; i < posts.length; i += chunk, j++) { chunkedArray[j] = posts.slice(i,i+chunk); } console.log(chunkedArray);