Can someone give me a hand with what the issue is? I’ve spent like two hours already…
It’s exactly with the input in this example that I’m getting the issue.
var result = [];
function chunkArrayInGroups(arr, size) {
if(size < arr.length){
let siRe = (arr.length%size!=0 ? 1 + parseInt(arr.length/size) :arr.length/size);
console.log('Numbers of arrays within the result: '+siRe);
for (let i = 0; i < siRe; i++){
if(arr[i] !== ''){
result[i] = (arr.splice(0,size));
console.log('Array #'+ (i + 1) + ': '+ result[i]);
}
else{
break;
}
}
}
else{
return arr;
}
return result;
}
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4));