Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 747 Bytes

zip.md

File metadata and controls

35 lines (23 loc) · 747 Bytes

arrays.zip

zip(arrayA, ArrayB, [func=(a,b)])

Zip applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.

Arguments

  1. arrayA (Array): input array
  2. ArrayB (Array): input array
  3. [func=(a,b)] (Function): to be applied to corresponding values

Returns

(Array): input array filled value pairs after the function has been applied

Example

const result = zip([5, 12, 8, 130, 44], ["ham", "cheese", "bread"]);
console.log(result)
> [ [ 'ham', 5 ], [ 'cheese', 12 ], [ 'bread', 8 ] ]