Finding the largest numbers in a subarray - Javascript Array Operation

Javascript examples for Array Operation:Array Search

Description

Finding the largest numbers in a subarray

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*w w  w  . j  a va 2s .  c  o m*/
var largest = function largest(arr) {
    return arr.map(function(arr) {
        return Math.max.apply(null, arr);
    });
};
console.log(largest([[41, 15, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]));
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials