Last active
December 29, 2015 20:53
-
-
Save jgarciaruiz/f3dcbd0759a9a22aace7 to your computer and use it in GitHub Desktop.
Using apply function to find out the maximum/minimum value 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
var numbers = [342, 16, 8, 345, 23, 436, 75]; | |
highestVal(numbers);//436 | |
lowestVal(numbers);//8 | |
function highestVal(array){ | |
var highestN = Math.max.apply(Math, array) | |
return highestN; | |
} | |
function lowestVal(array){ | |
var lowestN = Math.min.apply(Math, array) | |
return lowestN; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment