Last active
December 27, 2016 10:00
-
-
Save santosh/11597f5cfa4bab6419999296b31f0e25 to your computer and use it in GitHub Desktop.
Find the minimum number in an array. #JavaScript
This file contains hidden or 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 arrayMinimum(inputArray) { | |
var indexOfMinimum = 0; | |
for (var i = 1; i < inputArray.length; i++) { | |
if (inputArray[i] < inputArray[indexOfMinimum]) { | |
indexOfMinimum = i; | |
} | |
} | |
return inputArray[indexOfMinimum] ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment