Hello, I am currently attempting to integrate this function into my code:
Array.getMaximum = function (array) {
return Math.max.apply(Math, array);
};
Array.getMinimum = function (array) {
return Math.min.apply(Math, array);
};
This is inspired by the discussion on: JavaScript: min & max Array values?. However, when I try to execute it using:
console.log(myArr.getMax());
where
myArr = [245, 3, 40, 89, 736, 19, 138, 240, 42]
I encounter the following Error:
Uncaught TypeError: Object [object Array] has no method 'getMax'
Could someone assist me with resolving this issue?