const arr = [ {state: 0}, {state: 1}, {state: 4}, {state: 2}, {state: 4}, {state: 0}, {state: 3}, ] function group(array, subGroupLength) { var index = 0; var newArray = []; while(index < array.length) { newArray.push(array.slice(index, index += subGroupLength)); } return newArray; } var groupedCountries = group(arr, 3); console.log(groupedCountries)