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
function maxElement(arr) { | |
let max = Math.max.apply(null, arr) | |
return max; | |
} | |
let result = maxElement([7, 5, 33, 3]); | |
console.log(result) |
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
function maxElement(arr) { | |
// Using Rest parameter gives us an unpacked version of the array. | |
let max = Math.max(...arr) | |
return max; | |
} | |
let result = maxElement([7, 5, 33, 3]); | |
console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment