challenge-algorithms-v2.0-a.../03-maxValue/index.js
2022-11-02 15:07:34 -03:00

10 lines
196 B
JavaScript

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