programming-examples/js/Math/Find the highest value in an array.js
2019-11-15 12:59:38 +01:00

8 lines
232 B
JavaScript

function max(input) {
if (toString.call(input) !== "[object Array]")
return false;
return Math.max.apply(null, input);
}
console.log(max([12,34,56,1]));
console.log(max([-12,-34,0,-56,-1]));