This code is working but if I change N.max
to this.max
it stops working.
I wonder why it doesn't work
const N = {
min: function(arr) {
arr.sort((a, b) => a - b);
return arr.reduce(function(a, b) {
return a * b / N.max(a, b); // here
});
},
max: (a, b) => (b) ? N.max(b, a % b) : a // and here
}
let arr = [2, 6, 8, 14];
console.log(N.min(arr));