Created
March 22, 2018 18:29
-
-
Save jhsuZerion/e7e3ee778c7f03ac92264d5dc8b44115 to your computer and use it in GitHub Desktop.
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
/** | |
* Find the minimum value of an element in a subform | |
* @param {array} myArray Subform | |
* @param {string} column Data column name to aggregate | |
* @return {int|boolean} The minimum value found, or false if array is undefined or data column name is not found | |
*/ | |
function getMin(myArray, column) { | |
if (typeof myArray == "undefined" || myArray == null || Array.isArray(myArray) === false) return false; | |
var min_value = false; | |
for (var i = 0; i < myArray.length; i++) { | |
if (typeof myArray[i][column] !== "undefined") { | |
if (min_value === false) { | |
min_value = myArray[i][column]; | |
} else { | |
if (Number(min_value) > Number(myArray[i][column])) { | |
min_value = myArray[i][column]; | |
} | |
} | |
} | |
} | |
return min_value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment