diff options
| author | KUEPPO <tcheukueppo@tutanota.com> | 2022-10-16 22:17:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-16 22:17:29 +0100 |
| commit | b73cd3b8914bb53672a49c95f0ab297ed1a8b509 (patch) | |
| tree | a5e3c46c9c010bb573b941f5ead06618dec813c6 | |
| parent | 3aafc7cd4e7c2a519b4651ac21e5d1e81c8f9511 (diff) | |
| download | perlweeklychallenge-club-b73cd3b8914bb53672a49c95f0ab297ed1a8b509.tar.gz perlweeklychallenge-club-b73cd3b8914bb53672a49c95f0ab297ed1a8b509.tar.bz2 perlweeklychallenge-club-b73cd3b8914bb53672a49c95f0ab297ed1a8b509.zip | |
pwc-186, ch-1 in Node
| -rw-r--r-- | challenge-186/kueppo-wesley/Node/ch-1.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-186/kueppo-wesley/Node/ch-1.js b/challenge-186/kueppo-wesley/Node/ch-1.js new file mode 100644 index 0000000000..b18b36f5cc --- /dev/null +++ b/challenge-186/kueppo-wesley/Node/ch-1.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +'use strict'; + +function zip( ...lists ) { + let results = []; + [ ...Array( lists.map( item => item.length ).sort()[0] ).keys() ].forEach( index => results.push( ...lists.map(item => item[index]) ) ); + return results; +} + +let a = [ 1, 2, 3 ], b = [ 'a', 'b', 'c' ], c = ['e', 'f', ...a ]; + +console.log( zip(a, b) ); +console.log( zip(b, a) ); +console.log( zip(c, a) ); +console.log( zip(b, c, a) ); |
