0

I want to transform one array of arrays by doing a specific transform, like the following example:

[[1, 2, 3], [4, 5]]  => [14, 15, 24, 25, 34, 35];

Note, the first element of the first array is concatenated to each element of the second array to form a new array, and so on with the second element, third... etc

AGE
  • 3,604
  • 3
  • 35
  • 58
Ritchi
  • 71
  • 2
  • 4
  • Note really. Another exemple of what i want to achieve: `[[1, 2, 3], [4, 5]] => [14, 15, 24, 25, 34, 35];` – Ritchi Jun 16 '21 at 15:16
  • I don't think you mean to concatenate arrays, you mean a specific transformation, I advice you to correct your question and its description – AGE Jun 16 '21 at 15:24

1 Answers1

0

Use array.concat and for loop

let arrays =   [
  ["a1","b1","c1"],
  ["a2","b2","c2"],
  ["a1","b1","c1"],
  ["a1","b1","c1"],
]
let arr = [];
arrays.forEach(array =>{
    arr = arr.concat(array)
})

console.log(arr)
Sanmeet
  • 1,092
  • 1
  • 5
  • 12