Javascript flat and flatMap
The Array object has 2 methods to flatten arrays.
Array.flat will flatten a multidemsional array. It will flatten 1 level by default. You can specify how many levels to flatten.
flatMap flattens the result of a map.