Update chunk-array.md

Fix chunk array result
This commit is contained in:
fpluquet
2017-12-15 09:47:57 +01:00
committed by GitHub
parent c286d55182
commit 129f31e08d

View File

@ -7,5 +7,5 @@ If the original array can't be split evenly, the final chunk will contain the re
```js
const chunk = (arr, size) =>
Array.from({length: Math.ceil(arr.length / size)}, (v, i) => arr.slice(i * size, i * size + size));
// chunk([1,2,3,4,5], 2) -> [[1,2],[3,4],5]
// chunk([1,2,3,4,5], 2) -> [[1,2],[3,4],[5]]
```