From b52c44f39b2a8fedad384d27e12621a857500252 Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Fri, 28 Oct 2022 19:58:55 -0300 Subject: [PATCH 01/11] (feat)finalizando teste 01 greeting --- .gitignore | 1 + 01-greeting/index.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/01-greeting/index.js b/01-greeting/index.js index 8f551af..f99d6be 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,4 @@ export function greet(name) { - // implementar logica aqui - return ""; + + return `Hello ${name}`; } From 8e78769206398a2c3cfddd796112885324fb4e92 Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Fri, 28 Oct 2022 20:06:23 -0300 Subject: [PATCH 02/11] (feat)finalizando teste 02 triagleArea --- 02-triangleArea/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..3cf4ee7 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,3 @@ export function triangleArea(base, height) { - // your code here + return(base*height)/2 } \ No newline at end of file From e7260ebf672506fb5c75c11092e255e3e7285da1 Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Fri, 28 Oct 2022 20:13:28 -0300 Subject: [PATCH 03/11] (feat)finalizando teste 03 maxValue --- 03-maxValue/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..faa5d6e 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,11 @@ export function maxValue(values) { - // implementar logica aqui - + if (values == `${[]}`) { + return 0 + + } else { + + return Math.max.apply(null, values); + + } + } \ No newline at end of file From c31eca56ff096c3d8fbfcb8205b6765c6b0ad233 Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Fri, 28 Oct 2022 20:17:52 -0300 Subject: [PATCH 04/11] (feat)finalizando teste 04 fibonacci --- 04-fibonacci/index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..e6cddd0 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,17 @@ export function fibonacci(value) { - // implementar logica aqui - + if (value < 1) return 0 + if (value <= 2) return 1 + let fibonnaci1 = 0 + let fibonnaci2 = 1 + let fibx = value + + for (let i = 2; i <= value; i++) { + + fibx = fibonnaci2 + fibonnaci1 + fibonnaci1 = fibonnaci2 + fibonnaci2 = fibx + } + + return fibx + } \ No newline at end of file From 09f4747e46eed4bc1b247e480458ec72bf5dc9ad Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Fri, 28 Oct 2022 20:21:57 -0300 Subject: [PATCH 05/11] (feat)finalizando o teste 05 isPrime --- 05-isPrime/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..2f59911 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,10 @@ export function isPrime(value) { - // implementar logica aqui - + for (let i = 2; i < value; i++) { + if (value % i == 0) { + return false + } + + } + return value > 1 + } \ No newline at end of file From ba1669b1ec443f627518846d0105c277f980180c Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Fri, 28 Oct 2022 20:36:08 -0300 Subject: [PATCH 06/11] (feat)finalizando teste 06-sum --- 06-sum/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..b32c77a 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,11 @@ export function sum(values) { - // implementar logica aqui - + if (values.length) { + + return values.reduce(function (soma, i) { + + return soma + i + }) + } + return 0 + } \ No newline at end of file From 04733cc127c5d1a8ae5d1fd9e3deede07a166602 Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Fri, 28 Oct 2022 20:42:03 -0300 Subject: [PATCH 07/11] =?UTF-8?q?(refactor)retorno=20esperado=20da=20linha?= =?UTF-8?q?=2043=20estava=20replicado=20no=20da=20linha=2047,=20foi=20prec?= =?UTF-8?q?iso=20alterar=20para=20o=20retorno=20correto=20que=20era=20-40?= =?UTF-8?q?=20para=20que=20o=20c=C3=B3digo=20desse=20certo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 06-sum/index.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/06-sum/index.test.js b/06-sum/index.test.js index a1c8d55..8dcce2a 100644 --- a/06-sum/index.test.js +++ b/06-sum/index.test.js @@ -44,6 +44,6 @@ describe("sum", () => { }); it("Dever retornar -40 quando passamos o array [-2, -7, -31]", () => { - expect(sum([-2, -7, -31])).toBe(-51); + expect(sum([-2, -7, -31])).toBe(-40); }) }); \ No newline at end of file From 41336757a9f35d842a3e02612568e99f506f6a50 Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Fri, 28 Oct 2022 20:50:13 -0300 Subject: [PATCH 08/11] (feat) finalizando teste 07-sumEven --- 07-sumEven/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..9ae806f 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,10 @@ export function sumEven(value) { - // implementar logica aqui - + let resultado = 0 + for (const number of value) { + if (number % 2 == 0) { + resultado += number + } + } + return resultado + } \ No newline at end of file From 7977d238da1ad998aea5799b46c4e91bdde1d22e Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Mon, 31 Oct 2022 19:06:51 -0300 Subject: [PATCH 09/11] =?UTF-8?q?(feat)finalizando=20o=20teste=2008-isAnag?= =?UTF-8?q?ram=20(refactor)=20o=20index.test.js=20estava=20com=20com=20ace?= =?UTF-8?q?ntos=20no=20=C3=AD=20e=20apontava=20como=20referen=C3=A7a=20de?= =?UTF-8?q?=20erro=20foi=20nescessario=20alterar=20para=20poder=20prosegui?= =?UTF-8?q?r=20com=20o=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08-isAnagram/index.js | 30 +++++++++++++++++++++++++++--- 08-isAnagram/index.test.js | 10 +++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..b4afb74 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,28 @@ export function isAnagram(word1, word2) { - // implementar logica aqui - -} \ No newline at end of file + + if (word1.length !== word2.length) { + return false; + } else { + if ( + word1.toLowerCase().split("").sort().join("") === + word2.toLowerCase().split("").sort().join("") + ) { + return true; + } else { + return false; + } + } +} + + + + + + + + + + + + + diff --git a/08-isAnagram/index.test.js b/08-isAnagram/index.test.js index 4d7c8a7..b2998f9 100644 --- a/08-isAnagram/index.test.js +++ b/08-isAnagram/index.test.js @@ -5,23 +5,23 @@ describe("isAnagram", () => { expect(isAnagram("roma", "amor")).toBe(true); }); - ít("Dever retornar true quando passamos as palavras \"Buckethead\" e \"DeathCubeK\"", () => { + it("Dever retornar true quando passamos as palavras \"Buckethead\" e \"DeathCubeK\"", () => { expect(isAnagram("Buckethead", "DeathCubeK")).toBe(true); }); - ít("Dever retornar true quando passamos as palavras \"Twoo\" e \"WooT\"", () => { + it("Dever retornar true quando passamos as palavras \"Twoo\" e \"WooT\"", () => { expect(isAnagram("Twoo", "WooT")).toBe(true); }); - ít("Dever retornar false quando passamos as palavras \"dumble\" e \"bumble\"", () => { + it("Dever retornar false quando passamos as palavras \"dumble\" e \"bumble\"", () => { expect(isAnagram("dumble", "bumble")).toBe(false); }); - ít("Dever retornar false quando passamos as palavras \"ound\" e \"round\"", () => { + it("Dever retornar false quando passamos as palavras \"ound\" e \"round\"", () => { expect(isAnagram("ound", "round")).toBe(false); }); - ít("Dever retornar false quando passamos as palavras \"apple\" e \"pale\"", () => { + it("Dever retornar false quando passamos as palavras \"apple\" e \"pale\"", () => { expect(isAnagram("apple", "pale")).toBe(false); }); }); \ No newline at end of file From 61b8dc538c07b49afc911b19e365c88586c3ef26 Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Tue, 1 Nov 2022 13:47:11 -0300 Subject: [PATCH 10/11] (feat)finalizando teste 09-mostRepeatedChar --- 09-mostRepeatedChar/index.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..8b914b9 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,28 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" -} \ No newline at end of file + + + const palavra = {}; + let maximo = 0; + let repetido = ''; + + for(let letra of text){ + if(palavra[letra]){ + palavra[letra]++; + }else{ + palavra[letra] = 1; + } + } + + for(let letra in palavra){ + if(palavra[letra] > maximo){ + maximo = palavra[letra]; + repetido = letra; + } + } + + return repetido +} + + + + \ No newline at end of file From f577fc0a57f97b9e22391950a2847e511ff06f5b Mon Sep 17 00:00:00 2001 From: wellington carlos Date: Wed, 2 Nov 2022 14:52:14 -0300 Subject: [PATCH 11/11] (feat) finalizando o teste 10-longestWords --- 10-longestWords/index.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..377fa39 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,24 @@ export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + + let letra = words + let tamanho = 0 + let maximo = [' '] + + for (let i = 0; i < letra.length; i++) { + if (letra[i].length >= tamanho) { + tamanho = letra[i].length + if (maximo[maximo.length - 1].length < letra[i].length) { + maximo = [] + maximo.push(letra[i]) + } + else { + maximo = [...maximo, letra[i]] + } + } + } + return [...maximo] +} + + + +