loading...

re: Array Chunking VIEW POST

FULL DISCUSSION
 

another simple loop version

  const toChunks = (arr, chunkLength) => {
    const chunks = []
    let i, j, chunk
    for (i = 0, j = arr.length; i < j; i += chunkLength) {
      chunk = arr.slice(i, i + chunkLength)
      chunks.push(chunk)
    }
    return chunks
  }
Code of Conduct Report abuse