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

15 lines
232 B
JavaScript
Raw Normal View History

export function maxValue(values) {
2022-10-28 21:31:47 +00:00
let max = 0;
max = values[0];
2022-10-28 21:31:47 +00:00
if (values.length === 0){
return 0;
}
for(let i= 0; i < values.length; i++) {
if (values[i] > max) {
max = values[i];
}
}
return max;
}