Skip to content

Instantly share code, notes, and snippets.

@AndriiBozh
Created January 10, 2018 15:49
Show Gist options
  • Save AndriiBozh/1459de9dc64df78314bbe4bc82dcc231 to your computer and use it in GitHub Desktop.
Save AndriiBozh/1459de9dc64df78314bbe4bc82dcc231 to your computer and use it in GitHub Desktop.
Return Largest Numbers in Arrays (freeCodeCamp challenge)
//Return an array consisting of the largest number from each provided sub-array.
function largestOfFour(arr) {
var largest = arr.map(function(val){
return Math.max(...val); // ES6 syntax, equivalent to "return Math.max.apply(null, val);"
});
return largest;
}
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