Skip to content

Instantly share code, notes, and snippets.

@santosh
Last active December 27, 2016 10:00
Show Gist options
  • Save santosh/11597f5cfa4bab6419999296b31f0e25 to your computer and use it in GitHub Desktop.
Save santosh/11597f5cfa4bab6419999296b31f0e25 to your computer and use it in GitHub Desktop.
Find the minimum number in an array. #JavaScript
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