javascript - Concatenation of arrays -
how parse each index of 3 arrays of string , concatenate each value same index, have 1 array?
example input :
index 0 of array 1 value : "car" index 0 of array 2 value : "red" index 0 of array 3 value : "nikolai"
expected output, array (all in one) :
index 0 value : "car , red , nikolai"
for generic case want concatenation happen index 1, index 2, ...etc, can use es6 function:
function jointransposed(delim, ...args) { return args[0].map( (_, i) => args.map(w => w[i]).join(delim) ); } // example var = ["c", "y", "s", "h"], b = ["a", "o", "e", "i"], c = ["n", "u", "e", "m"]; var res = jointransposed(' , ', a, b, c); console.log(res);
Comments
Post a Comment