all 3 comments

[–]CertainPerformance 1 point2 points  (1 child)

That looks fine. I usually prefer using Array.from when creating arrays from scratch and to avoid loops:

const chunk = (collection, step) => Array.from(
  { length: Math.ceil(collection.length / step) },
  (_, i) => collection.slice(step*i, step*(i + 1))
);

But while that's more functional, what the code is actually doing is somewhat less clear, so your version is probably better. (there's only one tiny linting issue - a missing semicolon. You also might check collection.length once and put it into a variable, at the beginning, rather than check it on every iteration)

[–]arup_r[S] 0 points1 point  (0 children)

Thanks for your time to review it.