diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..851531e 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,12 @@ export function maxValue(values) { // implementar logica aqui - -} \ No newline at end of file + if(values.length == 0) return 0 + + const maxValue = values.reduce(function(a, b) { + return Math.max(a, b); + }, -Infinity); + + return maxValue +} + +maxValue([10, 40, 30, 20, 50]) // 50 \ No newline at end of file