Review My solution to Chunky Monkey

Review My solution to Chunky Monkey
0.0 0

#1
function chunkArrayInGroups(arr, size) {
  
  var result=[];  var j=1;
  var myArray = arr.slice();
  
    for (var i=0; i<arr.length/size;  i++){
         result[i]  = myArray.slice(i*size, size*j);
         j=j+1 ;
     }
  return result;
}

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

#2

You can remove the following line:

var myArray = arr.slice();

and then replace myArray with arr on the following line:

result[i]  = myArray.slice(i*size, size*j);

#3

yes , i don’t really need the Array.

result[i]  = arr.slice(i*size, size*j);

.