Basic Algorithm Scripting - Chunky Monkey Test case matches but does not accept it on FCC Code Editor

Tell us what’s happening:

I’ve tested my code on different compilers and produces the similar test case results, however the FCC code editor does not seem to work on it. What am I missing here?

Your code so far

function chunkArrayInGroups(arr, size) {
  let individualArr = [];
  let chunkArr = [];
  while(size<=arr.length){
    individualArr = arr.splice(0,size);
    chunkArr.push(individualArr);
  }
  if(arr.length!==0){
    excessArr = arr.splice(0);
    chunkArr.push(excessArr);
    arr = chunkArr;
  }else{
      arr = chunkArr;
  }
  return arr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Challenge Information:

Basic Algorithm Scripting - Chunky Monkey

Editor runs in a strict mode, this means all variables has to be declared.
If you change 9th line to the following, all tests are passing:

const excessArr = arr.splice(0);
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.