Skip to content

Instantly share code, notes, and snippets.

@AdrianSkar
Last active May 7, 2018 12:22
Show Gist options
  • Save AdrianSkar/44fcc07bcc3c03dca35e6021cde4f549 to your computer and use it in GitHub Desktop.
Save AdrianSkar/44fcc07bcc3c03dca35e6021cde4f549 to your computer and use it in GitHub Desktop.
function largestOfFour(arr) {
for (i=arr.length-1; i>=0; i--){
arr[i] = Math.max.apply(null, arr[i]); // I was thinking on doing it with max and reduce buy this looks cleaner
// Using ES6's spread operator: arr[i] = Math.max(...arr[i]);
}
return arr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment