Skip to content

Instantly share code, notes, and snippets.

@ar2zee
Created December 25, 2017 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ar2zee/b11e5dd186d996e81f9862772187375b to your computer and use it in GitHub Desktop.
Save ar2zee/b11e5dd186d996e81f9862772187375b to your computer and use it in GitHub Desktop.
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