split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument).
function chunkArrayInGroups(arr, size) {
let newArr = [];
while (arr.length > 0) {
newArr.push(arr.splice(0, size));
}
return newArr;
}