challenge-algorithms-v2.0-a.../03-maxValue/index.js

11 lines
193 B
JavaScript
Raw Normal View History

export function maxValue(values) {
2022-11-02 17:50:03 +00:00
var arr = values;
2022-11-02 14:59:41 +00:00
2022-11-02 17:50:03 +00:00
if (arr.length == 0) return 0;
var max1 = arr.reduce(function (a, b) {
return Math.max(a, b);
}, -Infinity);
return max1;
}