I have this following function, where Math.max() is not working as expected. It is always alerting the 1st value from the arguments that are passing. Where is the mistake?
function large(arr) {
   alert(Math.max(arr))
}
large(1,2,3,4,5);
You are passing multiple arguments, but your function only uses the first one.
In ES5 and before, you can use the apply method of a function  and the arguments object:
function large() { 
   alert(Math.max.apply(Math, arguments)) 
} 
large(1,2,3,4,5);
In ES6 you can use the rest and spread operator:
function large(...arr) { 
   alert(Math.max(...arr)) 
} 
large(1,2,3,4,5);
Function.prototype.apply() in use, here.
arrto the first argument. The other argument values are only accessible through theargumentskeyword.