Write chunk(array, size) that splits array into groups of at most size elements, in order. The final chunk may be shorter. If size is less than 1, return an empty array.
Signature: chunk(array, size) => any[][]
Example: chunk([1,2,3,4,5], 2) → [[1,2],[3,4],[5]].
Step through the array in increments of size.
array.slice(i, i + size) grabs one chunk.
Test natijalarini ko'rish uchun kodingizni ishga tushiring.