Can't pass test with correct answer

I’m not sure if i’m missing something or not. In the '" Basic Algorithm Scripting: Chunky Monkey" my code
returns the expected result ,but it doesn’t pass any test. What am i missing?

function chunkarrInGroups(arr, size) {

  let arr1 = [];
  let arr2 = [];

  for (let i = 0; i < arr.length; i++) {

    arr1.push(arr[i]);
    if (arr1.length == size || arr.length == i+1) {
      arr2.push(arr1);
      arr1 = [];
    }

  }

  // Break it up.
    console.log(arr2);

  return arr2;
}

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

Take a look at the tests that are failing - what is the function name those tests are calling? And what is your function’s name?

For the record, making just that change? Your code passes fine.

1 Like

I refactored the code to change ‘array’ to ‘arr’, and didn’t notice that it changed the name of the function as well. I would never remember to check the name of the function, thanks a lot.