Skip to content

Instantly share code, notes, and snippets.

@ar2zee
Created December 25, 2017 21:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Max element of each array using spread operator
var arr = [[4, 2, 7, 1], [20, 70, 40, 90], [1, 2, 0], [1, 2, 0] , [1, 2, 0] , [1, 2, 0]]; // ➞ [7, 90, 2]
function findLargestNums(arr) {
return arr.map(x => Math.max(...x));
}
console.log(findLargestNums(arr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment