From 8586343e12f3cf7f0d2f8037b0cb40a5c2dad43d Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:22:17 -0300 Subject: [PATCH 01/13] feat(home): adicionando resolucao do desafio 1 greeting --- 01-greeting/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/01-greeting/index.js b/01-greeting/index.js index 8f551af..4bef4b0 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,5 @@ export function greet(name) { // implementar logica aqui - return ""; + const frase = `Hello ${name}`; + return frase; } From a6170f5d7951daf784d8f49b8a1873ca4e137f30 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:33:52 -0300 Subject: [PATCH 02/13] feat(triangleArea): adicionando resolucao do desafio 2 triangleArea --- 02-triangleArea/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..5fedc42 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,5 @@ export function triangleArea(base, height) { // your code here + const area = (base * height) / 2; + return area; } \ No newline at end of file From 39ef165e71ca1cce0e5d182fdbaa4fd9b5ab50a5 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:41:44 -0300 Subject: [PATCH 03/13] feat(maxValue): adicionando resolucao do desafio 3 maxValue --- 03-maxValue/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..e357a27 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,9 @@ export function maxValue(values) { // implementar logica aqui - + if (values.length < 1) { + return 0; + } + const maior = Math.max(...values); + + return maior; } \ No newline at end of file From aaf3badf7ba2807b4c405ccc20be315902671ba7 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:44:45 -0300 Subject: [PATCH 04/13] feat(fibonacci): adicionando resolucao desfaio 4 fibonacci --- 04-fibonacci/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..7348d46 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,9 @@ export function fibonacci(value) { // implementar logica aqui - + if (value <= 1) { + return value; + } + + const resultado = fibonacci(value - 1) + fibonacci(value - 2); + return resultado; } \ No newline at end of file From e9ebef8951fc20a9bf49ea816b912a85b62129fd Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:46:14 -0300 Subject: [PATCH 05/13] feat(isPrime): adicionando resolucao desafio 5 isPrime --- 05-isPrime/index.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..6f72492 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,22 @@ export function isPrime(value) { // implementar logica aqui - + let totalDivisores = 0; + + for (let i = 1; i <= value; i++) { + if (value % i == 0) { + totalDivisores++ + } + } + + if (totalDivisores == 2) { + return true; + } else return false + + if (value === 2) { + return true; + } + + if (value === 1) { + return false; + } } \ No newline at end of file From 8ca33e4b4b88cc99ceb1f69bdabc8d5a25752e8c Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:50:11 -0300 Subject: [PATCH 06/13] feat(sum): adicionando resolucao desafio 6 sum --- 06-sum/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..911b188 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,8 @@ export function sum(values) { // implementar logica aqui - + let soma = 0; + for (let i = 0; i < values.length; i++) { + soma += values[i]; + } + return soma; } \ No newline at end of file From a51c45d47cebb7bc4c1b8d31445baf86bd356ecc Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:51:33 -0300 Subject: [PATCH 07/13] feat(sumEven): adicionando resolucao desafio 7 sumEven --- 07-sumEven/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..4759c1f 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,11 @@ export function sumEven(value) { // implementar logica aqui - + let soma = 0; + + for (let i = 0; i < value.length; i++) { + if (value[i] % 2 == 0) { + soma += value[i]; + } + } + return soma; } \ No newline at end of file From 78aaef7f2f05cb655b4607b0583a2b302da7b33d Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:53:19 -0300 Subject: [PATCH 08/13] feat(isAnagram): adicionando resolucao desafio 8 isAnagram --- 08-isAnagram/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..7dd2b77 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,13 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + let array = word1.toLowerCase().split('').sort(); + let array2 = word2.toLowerCase().split('').sort(); + + if (word1.length !== word2.length) { + return false; + } else { + if (array.toString() === array2.toString()) { + return true; + } else return false; + } } \ No newline at end of file From 940dba1b3852337679e0e4a0d7e0a717dfde2fa4 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:55:35 -0300 Subject: [PATCH 09/13] feat(mostUsedChar): adicionando resolucao desafio 9 mostRepeatedChar --- 09-mostRepeatedChar/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..12c72d9 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,15 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + const value = text.toLocaleLowerCase().split("").sort(); + + let counts = {}; + value.forEach(function (x) { + counts[x] = (counts[x] || 0) + 1; + }); + + const maior = Object.keys(counts).sort(function (a, b) { + return counts[a] > counts[b] ? -1 : counts[b] > counts[a] ? 1 : 0; + })[0]; + + return maior; } \ No newline at end of file From d443e5364ae4a1e53899b9da5dbeb41c940fdff3 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Sat, 29 Oct 2022 09:46:23 -0300 Subject: [PATCH 10/13] fix(fibonacci): melhorando resolucao fibonacci --- 04-fibonacci/index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 7348d46..de17e9a 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -4,6 +4,16 @@ export function fibonacci(value) { return value; } - const resultado = fibonacci(value - 1) + fibonacci(value - 2); - return resultado; -} \ No newline at end of file + // const resultado = fibonacci(value - 1) + fibonacci(value - 2); + // return resultado; + + let arr = [0, 1]; + + for (let i = 2; i < value + 1; i++) { + arr[i] = arr[i - 2] + arr[i - 1]; + } + return arr[value]; +} + +let f = fibonacci(46); +console.log(f); \ No newline at end of file From 712a0b5a6ed08aca898010d25e3143ac5f0491c8 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Sat, 29 Oct 2022 09:48:55 -0300 Subject: [PATCH 11/13] fix(fibonacci): retirando comentario de codigo antigo fibonacci --- 04-fibonacci/index.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index de17e9a..455d010 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -4,16 +4,10 @@ export function fibonacci(value) { return value; } - // const resultado = fibonacci(value - 1) + fibonacci(value - 2); - // return resultado; - let arr = [0, 1]; - + for (let i = 2; i < value + 1; i++) { arr[i] = arr[i - 2] + arr[i - 1]; } return arr[value]; -} - -let f = fibonacci(46); -console.log(f); \ No newline at end of file +} \ No newline at end of file From 07c54778f02c8335ee0ec4ee18e5fd3f095555f5 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Mon, 31 Oct 2022 10:26:28 -0300 Subject: [PATCH 12/13] feat(longestWords): adicionando resolucao desafio 10 longestWords --- 10-longestWords/index.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..5d8654e 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,23 @@ export function longestWords(words) { // implementar logica aqui - -} \ No newline at end of file + let maior = ""; + + for (const string of words) { + if (string.length > maior.length) { + maior = string; + } + } + + const maiores = words.filter((string) => string.length === maior.length); + + return maiores; + console.log(maiores); +} + + + + + +// console.log(longestWords(['oi', 'tudo', 'bem'])); +// console.log(longestWords(['Javascript', 'é', 'show'])); +console.log(longestWords(["abacaxi", "melancia", "bananana"])); \ No newline at end of file From f22d44c39b40afbebc1f44baea50a12ce73cc506 Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Tue, 1 Nov 2022 16:23:55 -0300 Subject: [PATCH 13/13] fix(longestWords): removendo testes feitos com console log 10-longestWords --- 10-longestWords/index.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index 5d8654e..08aaea9 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -7,17 +7,7 @@ export function longestWords(words) { maior = string; } } - const maiores = words.filter((string) => string.length === maior.length); return maiores; - console.log(maiores); -} - - - - - -// console.log(longestWords(['oi', 'tudo', 'bem'])); -// console.log(longestWords(['Javascript', 'é', 'show'])); -console.log(longestWords(["abacaxi", "melancia", "bananana"])); \ No newline at end of file +} \ No newline at end of file