DEV Community

Discussion on: Solving "Chunky Monkey" / freeCodeCamp Algorithm Challenges

Collapse
ttatsf profile image
tatsuo fukuchi

Another way:

const chunkArrayInGroups = (arr,  size) =>
  arr
  .flatMap(
    (_, i, a) => 
      i % size === 0 ? [ a.slice(i, i + size) ] 
      : []
  )
Collapse
virenb profile image
Viren B Author

Nice, more modern approach!