Read here. Code on desktop. The coding workspace opens on screens 1024px and wider.
JavaScript interview question
Chunk
easy10 min
Split an array into smaller groups of the requested size, keeping the original order.
Requirements
Implement chunk(array, size = 1). Each group has at most size elements; a final incomplete group is allowed.
Preserve element order. Return an empty array for an empty input or a size that is not a positive integer, including zero, negatives, fractions, NaN, and Infinity.
Return a new outer array and new group arrays without changing the input. Keep object references rather than deep-cloning values.
The input may contain any values. Preserve sparse slots within their corresponding groups.