constar=[2,4,10,[12,4,[100,99],4],[3,2,99],0];constmax=findMax(ar);println("Max = ",max);functionfindMax(array){// First we flatten the array using Infinity as depth// Then we sort the numbers from higher to lowerconstsortedFlatArray=array.flat(Infinity).sort((a,b)=>b-a);// First item it's the highestreturnsortedFlatArray[0];}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice one! I'd go with this one.