Can't pass chunky monkey

Can't pass chunky monkey
0

#1

All -

I can’t seem to pass the chunky monkey problem. When I run my code in repl.it, I get the correct answers but FCC is saying some of my return values are incorrect. Help?

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var sliceSize = Math.floor(arr.length / size);
  var modSize = arr.length % size;
  var x = 0;
  var newArr = [];
  
  for (var i = 0; i < sliceSize; i++) {
  	newArr[i] = arr.slice(x, x + size);
  	x += size;
  }
  
  if (modSize > 0) {
  	newArr[sliceSize + 1] = arr.slice(arr.length - modSize);
  }
  
  return newArr;
}

#3

That did it. Thanks. Your solution is MUCH more elegant than mine :frowning: