challenge-algorithms-v2.0-a.../03-maxValue/index.js
2022-11-02 14:50:03 -03:00

11 lines
193 B
JavaScript

export function maxValue(values) {
var arr = values;
if (arr.length == 0) return 0;
var max1 = arr.reduce(function (a, b) {
return Math.max(a, b);
}, -Infinity);
return max1;
}