find max element in array
JavaScript
var arr = [1, 4, 6, 3, 2];
console.log(Math.max.apply(null, arr));
Array.prototype.max = function() {
return Math.max.apply(null, this);
};
console.log(arr.max());
var arr = [1, 4, 6, 3, 2];
console.log(Math.max.apply(null, arr));
Array.prototype.max = function() {
return Math.max.apply(null, this);
};
console.log(arr.max());