Created
April 8, 2016 01:01
-
-
Save jslnriot/03e9089e684677c4fddf3587a4938884 to your computer and use it in GitHub Desktop.
create a function that gets the max number in an array
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
Array.prototype.max = function(){ | |
return this.reduce(function(prev,curr) { | |
return Math.max(prev,curr); | |
}); | |
} | |
arr = [1,2,4,3,6,3,7,8,2]; | |
console.log(arr.max()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment