Update snippet descriptions
This commit is contained in:
@ -3,11 +3,11 @@ title: zip
|
||||
tags: array,intermediate
|
||||
---
|
||||
|
||||
Creates an array of elements, grouped based on the position in the original arrays.
|
||||
Creates an array of elements, grouped based on their position in the original arrays.
|
||||
|
||||
- Use `Math.max.apply()` to get the longest array in the arguments.
|
||||
- Creates an array with that length as return value and use `Array.from()` with a map-function to create an array of grouped elements.
|
||||
- If lengths of the argument-arrays vary, `undefined` is used where no value could be found.
|
||||
- Use `Math.max()`, `Function.prototype.apply()` to get the longest array in the arguments.
|
||||
- Create an array with that length as return value and use `Array.from()` with a mapping function to create an array of grouped elements.
|
||||
- If lengths of the argument arrays vary, `undefined` is used where no value could be found.
|
||||
|
||||
```js
|
||||
const zip = (...arrays) => {
|
||||
|
||||
Reference in New Issue
Block a user