challenge-algorithms-v2.0-v.../03-maxValue/index.js
2022-10-28 07:50:23 -03:00

14 lines
315 B
JavaScript

export function maxValue(values) {
let highestValue = 0;
let firstTest = true;
for (let i = 0; i < values.length; i++){
if(firstTest === true){
highestValue = values[i];
}
firstTest = false;
if(values[i] > highestValue){
highestValue = values[i];
}
}
return highestValue;
}