0

I have an array of value and i want to extract all the subarray inside the array but i don't know how.

Here is the array :

[

    [
        "20:00",
        "21:00",
        "22:00"
    ],
    [
        "18:00",
        "19:00",
        "20:00"
    ],
    [
        "12:00",
        "13:00",
    ]
]

How can i make like this : [ "20:00", "21:00", "22:00", "18:00", "19:00", "20:00", "12:00", "13:00", "14:00" ]

1 Answers1

1

You can convert a multi-dimensional array structure to a flat array with Array.flat():

const arr = [["20:00","21:00","22:00"],["18:00","19:00","20:00"],["12:00","13:00"]]
    
const result = arr.flat()

console.log(result)
Ori Drori
  • 183,571
  • 29
  • 224
  • 209