Find largest number from a nested array in JavaScript
Advertisements
const arr = [[3,2,1], [4,5,6],[9,8,7]]; const max = Math.max(...[].concat(...arr)); const min = Math.min(...[].concat(...arr)); console.log(max); //9 console.log(min); //1
This solution works only for an array of arrays, not nested arrays.