Last active
December 26, 2017 19:02
-
-
Save AviTapp/6c6f80fdd2915671245d80db828b9721 to your computer and use it in GitHub Desktop.
Return an array consisting of the largest number from each provided sub-array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function largestOfEachSubarray(r) { | |
for (i = 0; i < r.length; i++) { | |
var a = r[i], | |
n = 0; | |
for (j = 0; j < a.length; j++) { | |
var t = a[j]; | |
n < t && (n = t) | |
} | |
r[i] = n | |
} | |
return r | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment