Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Chunk

Instructions

Given a list and chunk size, divide the list into multiple sub lists where each sub-list is of length of chunk size.

Challenge | Solution

Examples

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

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

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

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

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