I have array with objects codeData
, and I want to make array with arrays(in every array 3 objects) , and I made something like that:
let codeData = [{el: 1}, {el: 2} , {el: 3}, {el: 4}, {el: 5}, {el: 6}]
let arr = [...Array(Math.ceil(codeData.length / 3))].map(_ => codeData.splice(0, 3))
console.log(arr)
But it caused this error. How I can solve this?