131. implement _.chunk()

JavaScriptLodash

medium  - accepted / - tried

_.chunk() splits array into groups with the specific size.

Please implement your chunk(arr: any[], size: number)

chunk([1,2,3,4,5], 1)chunk([1,2,3,4,5], 2)chunk([1,2,3,4,5], 3)chunk([1,2,3,4,5], 4)chunk([1,2,3,4,5], 5)

for size smaller than 1, return an empty array.

Related Lists

lodash

Always try to find a better approach.