i have three arrays. H, E, and F.
const H = [
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, $, $, $, $, $, $, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
[$, _, _, _, _, _, _, $,],
]
const E = [
[$, $, $, $, $, $, $, $,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, $, $, $, $, $, $, $,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, $, $, $, $, $, $, $,],
]
const F = [
[$, $, $, $, $, $, $, $,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, $, $, $, $, $, $, $,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, _,],
];
i want following output: H E F which is:
[
[$, _, _, _, _, _, _, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $, $,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, _, _, _, _, _, _, _, $, _, _, _, _, _, _, _,],
[$, _, _, _, _, _, _, $, $, $, $, $, $, $, $, $, $, _, _, _, _, _, _, _,],
]
basically i want to combine HEF from H,E,F. any solution through looping or maybe if lodash provide this functionality? as this is array in array im open to looping solutions and any lodash or maybe if any javascript library provide this functionality then let me know.
>Solution :
Looks like you just need to apply concat to each row separately:
a = [
['a','b','c'],
['d','e','f'],
]
b = [
['g','h'],
['i','j'],
]
c = [
['k', 'l'],
['m', 'n'],
]
let glue = args => args[0].map(
(_, i) => [].concat(
...args.map(a => a[i])))
result = glue([a, b, c])
console.log(result)