From 7cbeb310944b6644713b2ac5c1017652ecf1087a Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sat, 29 Oct 2022 16:15:42 -0300 Subject: [PATCH 01/12] feat(01-greeting):completead first challenge --- 01-greeting/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-greeting/index.js b/01-greeting/index.js index 8f551af..5c0279c 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}`; } -- 2.34.1 From 6b149f7d16f92c58b0a519af4bbd97434525b7e5 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sat, 29 Oct 2022 16:20:16 -0300 Subject: [PATCH 02/12] feat(02-trianglearea):completead second challenge --- 02-triangleArea/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..c46256f 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,5 @@ export function triangleArea(base, height) { // your code here + let result = base * height / 2; + return result; } \ No newline at end of file -- 2.34.1 From 82346e67caea377a800f7737d6a5410fe1981318 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sat, 29 Oct 2022 16:25:05 -0300 Subject: [PATCH 03/12] feat(03-maxvalue):completead third challenge --- 03-maxValue/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..b3da162 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,14 @@ export function maxValue(values) { // implementar logica aqui - + if (values.length == 0){ + return 0; + } + return values.reduce((maiornum,atualnum) => { + if(maiornum > atualnum){ + return maiornum; + } + else{ + return atualnum; + } + }) } \ No newline at end of file -- 2.34.1 From 4552cc3b133e0944d65fb5d92f6e4c15977bad49 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sat, 29 Oct 2022 16:28:45 -0300 Subject: [PATCH 04/12] feat(04-fibonacci):completead fourth challenge --- 04-fibonacci/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..e4dd408 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,10 @@ export function fibonacci(value) { // implementar logica aqui - + if(value < 0) return 0; + if(value < 2) return value; + if(memo[value]) return memo[value]; + let result = fibonacci(value - 1, memo) + fibonacci(value - 2, memo); + memo[value] = result; + console.log(memo); + return result; } \ No newline at end of file -- 2.34.1 From 4ffe38af11bdc299a1776de07aa73649d2fa1012 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sat, 29 Oct 2022 16:31:50 -0300 Subject: [PATCH 05/12] feat(05-isprime):completead fifth challenge --- 05-isPrime/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..b939402 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,9 @@ export function isPrime(value) { // implementar logica aqui - + for (let i = 2; i < value; i++){ + if (value % i === 0){ + return false; + } +} + return value >= 2; } \ No newline at end of file -- 2.34.1 From 42a6fa7e73de43908fbc4b1b5c3b98c85c808c25 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sat, 29 Oct 2022 16:35:30 -0300 Subject: [PATCH 06/12] feat(06-sum):completead sixth challenge --- 06-sum/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..cab20d0 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,6 @@ export function sum(values) { // implementar logica aqui - + return values.reduce((totalnum, atualnum) => { + return totalnum + atualnum + }, 0) } \ No newline at end of file -- 2.34.1 From 21eda043e22ca8e39280e1dc179a9566a42d3bf7 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sat, 29 Oct 2022 16:39:33 -0300 Subject: [PATCH 07/12] feat(07-sumeven):completead seventh challenge --- 07-sumEven/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..8845d8b 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,8 @@ export function sumEven(value) { // implementar logica aqui - + value.forEach(element => { + if(element % 2 === 0) + resposta += element + }); + return resposta; } \ No newline at end of file -- 2.34.1 From 4b889f7c8479d65eba9d4dd7eb8d13fe52e8c8ca Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sun, 30 Oct 2022 16:29:12 -0300 Subject: [PATCH 08/12] feat(08-isanagram):completead eighth challenge --- 08-isAnagram/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..f46cf38 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,15 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + let palaminu1 = word1.toLowerCase(); + let palaminu2 = word2.toLowerCase(); + palaminu1 = palaminu1.split('') + palaminu2 = palaminu2.split('') + palaminu1 = palaminu1.sort() + palaminu2 = palaminu2.sort() + palaminu1 = palaminu1.join('') + palaminu2 = palaminu2.join('') + if(palaminu1 == palaminu2){ + return true; + } + return false; } \ No newline at end of file -- 2.34.1 From 3c50e566ab32d29d6469d3d47478a0dac1aaaf92 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Sun, 30 Oct 2022 17:29:47 -0300 Subject: [PATCH 09/12] feat(09-mostrepeatedchar):completead ninth challenge --- 09-mostRepeatedChar/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..54536cc 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,16 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + let caractercount = 0; let caractersave = {}; let caracter = " "; + text.split("").forEach((repetido) => { + if(caractersave[repetido]){ + caractersave[repetido] += 1; + } else{ + caractersave[repetido] = 1; + } + if(caractersave[repetido] > caractercount){ + caractercount = caractersave[repetido]; + caracter = repetido; + } + }); + return caracter; } \ No newline at end of file -- 2.34.1 From 146c2a9cc322e860e0e9ee78ea4d72a403c63b91 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Mon, 31 Oct 2022 18:28:35 -0300 Subject: [PATCH 10/12] feat(10-longestWords):completead tenth challenge --- 10-longestWords/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..a5dc5c1 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,12 @@ export function longestWords(words) { // implementar logica aqui - + let lista = []; + words.forEach(palavra => { + if(!lista[0] || lista[0].length < palavra.length){ + lista = [palavra] + } else if(lista[0].length == palavra.length){ + lista.push(palavra) + } + }); + return lista; } \ No newline at end of file -- 2.34.1 From cc129f3d5300f35e61539a1485636fd76653f24a Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Mon, 31 Oct 2022 18:35:31 -0300 Subject: [PATCH 11/12] fix(07-sumeven): created variable resposta --- 07-sumEven/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index 8845d8b..592c2ef 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,5 +1,6 @@ export function sumEven(value) { // implementar logica aqui + let resposta = 0 value.forEach(element => { if(element % 2 === 0) resposta += element -- 2.34.1 From 1d2ca3033784f0906fcb6c14143d98fb69441b67 Mon Sep 17 00:00:00 2001 From: MarcelloMartins Date: Mon, 31 Oct 2022 18:41:43 -0300 Subject: [PATCH 12/12] fix(04-fibonacci): created parameter memo --- 04-fibonacci/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index e4dd408..2720a04 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,10 +1,9 @@ -export function fibonacci(value) { +export function fibonacci(value,memo = {}) { // implementar logica aqui if(value < 0) return 0; if(value < 2) return value; if(memo[value]) return memo[value]; let result = fibonacci(value - 1, memo) + fibonacci(value - 2, memo); memo[value] = result; - console.log(memo); return result; } \ No newline at end of file -- 2.34.1