Javascript Array zip(xs, ys, modify)

Description

Javascript Array zip(xs, ys, modify)

Array.zip = function(xs, ys, modify) {
    const result = [];//from ww  w  .j a v  a2 s. co m

    for(let i = 0; i < Math.min(xs.length, ys.length); i++) {
        result.push(modify(xs[i], ys[i]));
    }

    return result;
}



PreviousNext

Related