This is the javascript I'm trying to run in the terminal via jsc:
calc_real_weights.js:
getElementWithLowestCount(someMatrix)
Array.prototype.max = function() {
return Math.max.apply(null, this);
};
Array.prototype.min = function() {
return Math.min.apply(null, this);
};
function getElementWithLowestCount(countAndWeightMatrix){
aux = []
for(var i = 0; i < countAndWeightMatrix.length; i++){
if (countAndWeightMatrix[i][0] < aux.min()){
var min = countAndWeightMatrix[i];
}
aux.push(countAndWeightMatrix[i][0]);
}
return min;
}
The error:
Borjas-MacBook-Pro:Algorithm borjagvo$ jsc calc_real_weights.js
Exception: TypeError: undefined is not a function (evaluating 'aux.min()')
getElementWithLowestCount@calc_real_weights.js:37:46
calcRealWights@calc_real_weights.js:46:45
global code@calc_real_weights.js:18:33
It looks like getElementWithLowestCount
doesn't see the Array prototype extension. How can I make it to see it?
Thanks.