forked from M3-Academy/challenge-algorithms-v2.0
Merge pull request 'refactor: altera solucao maxValue' (#11) from feature/solucao-maxValue into development
Reviewed-on: #11
This commit is contained in:
commit
793756bbf2
@ -1,8 +1,12 @@
|
|||||||
export function maxValue(values) {
|
export function maxValue(values) {
|
||||||
// implementar logica aqui
|
// implementar logica aqui
|
||||||
|
let max = values.reduce(function (a, b) {
|
||||||
|
return Math.max(a, b);
|
||||||
|
}, -Infinity);
|
||||||
|
|
||||||
if (values.length === 0) {
|
if (values.length === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return Math.max.apply(null, values);
|
return max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user