From 1231f40660222099cba3ec7e8b80c64b089167a5 Mon Sep 17 00:00:00 2001 From: Rafael Sampaio Date: Fri, 28 Oct 2022 15:01:37 -0300 Subject: [PATCH] refactor: altera solucao maxValue --- 03-maxValue/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index a78ce0f..93d537a 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,8 +1,12 @@ export function maxValue(values) { // implementar logica aqui + let max = values.reduce(function (a, b) { + return Math.max(a, b); + }, -Infinity); + if (values.length === 0) { return 0; } else { - return Math.max.apply(null, values); + return max; } }