From dc95b46ffea61992549be51a19e73e0fcb5f3f18 Mon Sep 17 00:00:00 2001 From: Saulo Klein Nery Date: Fri, 28 Oct 2022 13:00:20 -0300 Subject: [PATCH] =?UTF-8?q?feat(maxValue=20and=20fibonacci):=20Implementa?= =?UTF-8?q?=20fun=C3=A7=C3=A3o=20que=20retorna=20o=20maior=20valor=20do=20?= =?UTF-8?q?array=20e=20outra=20que=20calcula=20fibonacci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-maxValue/index.js | 13 +++++++++++++ 04-fibonacci/index.js | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..9000cac 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,17 @@ export function maxValue(values) { // implementar logica aqui + let maior = 0; + values.map( + (element, i) => { + if(i === 0) + maior = element; + + if(element > maior) + maior = element; + + } + ); + + return maior; } \ No newline at end of file diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..ebd1ee5 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,12 @@ export function fibonacci(value) { // implementar logica aqui + let a = 0, b = 1, c = value; + + for(let i = 2; i <= value; i++){ + c = a + b; + a = b; + b = c; + } + return c; } \ No newline at end of file