Skip to content

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.