Flatten a multidimensional associative array into one-dimensional array using javascript

Flatten a multidimensional associative array using javascript


function flattenArrays(arr) {

 return arr
    .flat(Infinity)
    .sort((a, b) => a - b);

}

console.log(flattenArrays([ ["hello", "04"], 
["3", "5", 
["world", ["10"], "11"]], 
[ 5, 6, 7, 8, 9]])
);

/*
output will be 
[
  '3', '04', '5',  5,
  6,   7,    '8',  8,
  9,   '10', '11', '18'
]
*/