Flatten array - Node.js Array

Node.js examples for Array:Flatten

Description

Flatten array

Demo Code


export function flatten(a) {
    const target = [];/*from   w w  w  .  ja va 2  s. c  om*/
    for (let i = 0; i < a.length; ++i) {
        for (let j = 0; j < a[i].length; ++j) {
            target.push(a[i][j]);
        }
    }
    return target;
}

Related Tutorials