FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Easy

Chunk

10mins

Implement a function chunk(array, size) that splits an array into multiple smaller arrays of the specified size.

Example

chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]] chunk([1, 2, 3, 4, 5, 6], 3); // [[1, 2, 3], [4, 5, 6]] chunk([1, 2, 3], 1); // [[1], [2], [3]]

Code Editor

JavaScript Function

00:00
Loading...

Test Cases

No test results yet

Click "Run" to execute tests