Skip to content

Instantly share code, notes, and snippets.

@AviTapp
Last active December 26, 2017 19:02
Show Gist options
  • Save AviTapp/6c6f80fdd2915671245d80db828b9721 to your computer and use it in GitHub Desktop.
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.
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