News for hackers. Stuff that matters.
Re:Zip Function Solution: Haskell, Elixir, JavaScript, Pytho... by m-r-r on Thursday November 10, 2022 @07:23AM (#33545411)
Yes, the JavaScript implementation doesn't works if the second array contains 'false', 'null', 'undefined', '0' or 'NaN'.

Here is my implementation of the 'zip' function in modern JavaScript. It is similar to the Vlang version, but it is generic over the number of arrays :

  const zip = (...arrays) => {
    const length = Math.min(...arrays.map((array) => array.length));
    return Array.from({ length }, (_, i) => arrays.map((array) => array[i]));
  };

There are no comments on this comment yet.