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

9 lines
203 B
JavaScript
Raw Normal View History

export function maxValue(values) {
2022-11-02 19:27:33 +00:00
if (values.length == 0) return 0;
const maxValue = values.reduce(function (prev, current) {
return prev > current ? prev : current;
});
return maxValue;
}