What approach is best for returning an array of max numbers for this array in JS?
[[[1,2,4],[3,4,6]],[[33,55,66],[99,4,55]]]
I want the result to be [4,6,66,99]
Use a nested map
and the spread operator with max
.
a=[[[1,2,4],[3,4,6]],[[33,55,66],[99,4,55]]];
document.write(a.map((a)=>a.map((a)=>Math.max(...a))));