From 00dff8d1364393a933a393cdcff7cf82836c20ab Mon Sep 17 00:00:00 2001 From: LeonardoPereiraRocha Date: Fri, 28 Oct 2022 18:31:47 -0300 Subject: [PATCH] =?UTF-8?q?feat(03-maxValue):=20Cria=20a=20fun=C3=A7=C3=A3?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-triangleArea/index.js | 2 +- 03-maxValue/index.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index ee6dd83..4cc7b32 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,5 +1,5 @@ export function triangleArea(base, height) { let result; result = (base * height) / 2; - return result + return result; } \ No newline at end of file diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..c195ce1 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,15 @@ export function maxValue(values) { - // implementar logica aqui + let max = 0; + max = values[0]; + if (values.length === 0){ + return 0; + } + + for(let i= 0; i < values.length; i++) { + if (values[i] > max) { + max = values[i]; + } +} + return max; } \ No newline at end of file