From 8b3a1206a60b9b80004fd2cf1bb221507fefa6a5 Mon Sep 17 00:00:00 2001 From: Marcela Mathias Date: Wed, 2 Nov 2022 16:27:33 -0300 Subject: [PATCH] add maxValue logic --- 03-maxValue/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..a8dd40f 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,8 @@ export function maxValue(values) { - // implementar logica aqui - -} \ No newline at end of file + if (values.length == 0) return 0; + const maxValue = values.reduce(function (prev, current) { + return prev > current ? prev : current; + }); + + return maxValue; +}