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

14 lines
269 B
JavaScript
Raw Normal View History

export function maxValue(values) {
let max = values[0];
if (values.length === 0) {
return 0;
} else {
for (let index = 0; index <= values.length; index++) {
if (max < values[index]) {
max = values[index];
}
}
return max;
}
}