function flattenAndSort(array) {
return array.flat().sort((a, b) => a - b);
}
//answer [1, 2, 3, 4, 5,6, 7, 8,9]
The flat() method creates a new array with sub-array elements concatenated to a specified depth and I am using sort() method for order sequence.
Top comments (0)