forked from M3-Academy/challenge-algorithms-v2.0
feat(maxValue): Adicionando algoritmo que retorna o valor maximo de um vetor.
This commit is contained in:
parent
5c5d0859ef
commit
e74fc971cf
@ -1,4 +1,13 @@
|
|||||||
export function maxValue(values) {
|
export function maxValue(values) {
|
||||||
// implementar logica aqui
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user