hello im trying to build this function into my code:
Array.max = function (array) {
return Math.max.apply(Math, array);
};
Array.min = function (array) {
return Math.min.apply(Math, array);
};
as dictated by: JavaScript: min & max Array values?. However when i try to call it using:
console.log(a.max());
where
a = [245, 3, 40, 89, 736, 19, 138, 240, 42]
I get the following Error:
Uncaught TypeError: Object [object Array] has no method 'max'
Can someone help me with this?