Skip to content
Advertisement

Tag: chunks

Splitting an array in equal parts

I am looking for a Javascript Algorithm to split an array into chunks, but avoiding any small left overs. For example: But I want this: So basically the output is spread over several arrays with a maximum number of elements passed in as second argument. Answer You should recalculate the size, which might need to be smaller than given. Then

Advertisement