Created
December 25, 2017 21:44
-
-
Save ar2zee/b11e5dd186d996e81f9862772187375b to your computer and use it in GitHub Desktop.
Max element of each array using spread operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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