Chunky monkey - how to decide on best method

Tell us what’s happening:
My code works, but it is different than any of the solutions. At this point in my learning, does it matter that I use the best performing method? How do I know what the best performing method is?

Your code so far

function chunkArrayInGroups(arr, size) {

let newArray = [];

for (let i=0; i<arr.length; i+=size) {
  newArray[i/size] = (arr.slice(i,i+size));

return newArray;

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15.

Challenge: Chunky Monkey

Link to the challenge:

  • Done is better than perfect.
  • It’s pretty common to solve a problem any way you can first and then look at it for opportunities to improve it. Much more common than doing it perfectly the first time.
  • Just because a solution is in the guide doesn’t mean its the best solution.

Honestly, the only thing I would change about your solution is that I would use newArray.push() instead of newArray[i/size] =. Otherwise, that’s how I would solve the problem.


Thank you, so much. I appreciate your answer.