Chunky monkey: undefined in first element of Array

Chunky monkey: undefined in first element of Array
0

#1

[],[0,1,2,],[3,4,5,],[6] is the output i get from the following code

function chunkArrayInGroups(arr, size) {

var newarr=[[]];// Break it up.
for (var i=0; i<arr.length; i+=size){
newarr.push(arr.slice(i,i+size) );
}

arr.shift();

return newarr;

}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3);


#2

Double check your variables- what are you initializing newarr to and why?


#3

changed newarr assignment to newarr=[ ];
Thank you