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

14 lines
315 B
JavaScript
Raw Normal View History

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;
}