Lodash _chunk solution with loops problem

Dear All,

I am trying to solve the Lodash chunk with 2 loops instead of .slice method.
https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-ii/modules/fecp-practice-javascript-syntax-arrays-loops-objects-iterators/projects/lodash.

Here is my code:

chunk(array,size=1)
{
let arrayChunks=;
for (let i=0; i< array.length; i=i+size)
{
let arrayChunk=;
for (j=0; j<size; j++)
{
arrayChunk.push(array[i+j]);
}
arrayChunks.push(arrayChunk);
}
return arrayChunks;
}
}

Unfortunately, I am getting an error code with uneven arrays:
node test/chunk.js
_.chunk() Tests:
1 - _.chunk() is defined - Passed!
2 - Returns an array - Passed!
3 - Chunks evenly-divided arrays - Passed!
4 - Chunks unevenly-divided arrays - Failed: _.chunk([1, 2, 3, 4, 5], 2) returned [ 1,2, 3,4, 5, ] instead of [ 1,2, 3,4, 5 ].

It is almost good but not quite so.

Please help!

Thank you,

Not really sure about the placement of the return statement.

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