I\'m trying to find a method to find the max value comparing multiple(unknown number, but same length) arrays for each observation in the arrays, returning an array with the max
For each index of the array, create an array containing all elements in the "column" and find the max of those values. Return the generated array. Sample usage: maxValues(A)
would give the desired result.
function maxValues(array) {
var maxArray = [];
var length = array[0].length;
for (var i = 0; i < length; i++) {
var ithColumn = [].map.call(array, function(array) {
return array[i];
});
maxArray.push(Math.max.apply(null, ithColumn));
}
return maxArray;
}