https://github.com/jackhowa/chunky-monkey
Work with arrays in JavaScript and algorithms
https://github.com/jackhowa/chunky-monkey
algorithm freecodecamp javascript
Last synced: 9 months ago
JSON representation
Work with arrays in JavaScript and algorithms
- Host: GitHub
- URL: https://github.com/jackhowa/chunky-monkey
- Owner: JackHowa
- Created: 2017-08-09T20:40:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-09T21:34:42.000Z (over 8 years ago)
- Last Synced: 2025-01-21T16:44:40.188Z (11 months ago)
- Topics: algorithm, freecodecamp, javascript
- Language: JavaScript
- Homepage: https://www.freecodecamp.org/challenges/chunky-monkey
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chunky Monkey
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
* chunkArrayInGroups(["a", "b", "c", "d"], 2) should return [["a", "b"], ["c", "d"]].
* chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3) should return [[0, 1, 2], [3, 4, 5]].
* chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2) should return [[0, 1], [2, 3], [4, 5]].
* chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4) should return [[0, 1, 2, 3], [4, 5]].
* chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3) should return [[0, 1, 2], [3, 4, 5], [6]].
* chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4) should return [[0, 1, 2, 3], [4, 5, 6, 7], [8]].
* chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2) should return [[0, 1], [2, 3], [4, 5], [6, 7], [8]].