Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Find the maximum number in a jagged array of numbers

function getMax(a){
  return Math.max(...a.map(e => Array.isArray(e) ? getMax(e) : e));
}

var ar = [2,4,10,[12,4,[100,99],4],[3,2,99],0]; 

 console.log(getMax(ar));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Find #maximum #number #jagged #array #numbers
ADD COMMENT
Topic
Name
9+7 =