From 3788117b5173fe180b36e6d5dbc61363706d258b Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Fri, 28 Oct 2022 14:04:06 -0300 Subject: [PATCH 01/11] feat(greet): Template string, funcional em todos os testes. --- 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}`; } From c7ec50ec8b4906db5483a211e5c2734c1c2abed1 Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Fri, 28 Oct 2022 14:08:31 -0300 Subject: [PATCH 02/11] =?UTF-8?q?feat(triangleArea):=20Retono=20da=20fun?= =?UTF-8?q?=C3=A7=C3=A3o,=20funcional=20em=20todos=20os=20testes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-triangleArea/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..53067fe 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,4 @@ export function triangleArea(base, height) { // your code here + return base * height /2 ; } \ No newline at end of file From d3a4147db9338ea61fd1678a49e80629fcd8dd2c Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Fri, 28 Oct 2022 14:20:56 -0300 Subject: [PATCH 03/11] =?UTF-8?q?feat(maxValue):=20if/else=20com=20verific?= =?UTF-8?q?a=C3=A7=C3=A3o=20do=20tamanho=20do=20array=20e=20Math.max,=20fu?= =?UTF-8?q?ncional=20em=20todos=20os=20testes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-maxValue/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..5187e63 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,8 @@ export function maxValue(values) { // implementar logica aqui - + if(values.length === 0){ + return 0 + } else { + return Math.max(...values) + } } \ No newline at end of file From aaed0ee98d5a0967843f262675a32fede40fbaa8 Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Sat, 29 Oct 2022 18:09:07 -0300 Subject: [PATCH 04/11] =?UTF-8?q?feat(fibonacci):=20condi=C3=A7=C3=B5es=20?= =?UTF-8?q?e=20loop=20utilizados=20na=20resolu=C3=A7=C3=A3o,=20funcional?= =?UTF-8?q?=20em=20todos=20os=20testes.=20Comentario=20com=20primeira=20lo?= =?UTF-8?q?gica,=20mas=20estava=20mal=20otimizada.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..73e275e 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,25 @@ export function fibonacci(value) { // implementar logica aqui - + if(value < 1) return 0 + if(value <=2) return 1 + let fibMin2 = 0 + let fibMin1 = 1 + let fibValue = value + for(let i = 2; i <= value; i++) { + fibValue = fibMin1 + fibMin2 + fibMin2 = fibMin1 + fibMin1 = fibValue + } + return fibValue + +// Forma inicial pensada, mas demorava muito tempo para passar nos testes. + + // if(value === 0) { + // return 0 + // } + // else if (value <= 2) { + // return 1 + // } + // return fibonacci(value - 1) + fibonacci(value - 2); + } \ No newline at end of file From f98db45a0358f26aed5e5c19b6fdd3d9371feafa Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Sat, 29 Oct 2022 18:50:55 -0300 Subject: [PATCH 05/11] feat(isPrime): Utilizando loop while, Math.sqrt para retornar a raiz dos valores passados, funcional em todos os testes. --- 05-isPrime/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..805d2b6 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,6 @@ export function isPrime(value) { // implementar logica aqui - + var start = 2; + while (start <= Math.sqrt(value)) if (value % start++ < 1) return false; + return value > 1; } \ No newline at end of file From 20a3ecf962795824d61f41c10403f5fa72333a25 Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Sat, 29 Oct 2022 19:30:33 -0300 Subject: [PATCH 06/11] feat(sum): Utilizando for in, para interagir com propriedades enumeradas, funcional em todos os testes. --- 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..dc904a4 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 in values) { + soma += values[i] + } + return soma } \ No newline at end of file From 3bc3385c9fdcaa46b2d4f3d723fd2a4feeb04b20 Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Tue, 1 Nov 2022 22:18:37 -0300 Subject: [PATCH 07/11] feat(sumEven): filter utilizado para retornar numeros pares e um for para fazer a soma do array --- 07-sumEven/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..b17535e 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,11 @@ export function sumEven(value) { // implementar logica aqui - -} \ No newline at end of file + var retorno = value.filter(pares => (pares %2)== 0); + let soma = 0 + for(let i in retorno) { + soma += retorno[i] + } + return soma +} + + From 712c72d45c3ae31aa3ac86ccb7171b74344546b9 Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Tue, 1 Nov 2022 22:31:51 -0300 Subject: [PATCH 08/11] =?UTF-8?q?feat(isAnagram):=20toLowerCase=20utilizad?= =?UTF-8?q?o=20para=20retornar=20as=20palavras=20todas=20minusculas=20para?= =?UTF-8?q?=20verifica=C3=A7=C3=A3o,=20if=20para=20condicional=20negativa,?= =?UTF-8?q?=20split=20para=20ordenar=20a=20string,=20join=20para=20retorna?= =?UTF-8?q?r=20a=20string=20junta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08-isAnagram/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..1361c11 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,13 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + let word1Lower = word1.toLowerCase() + let word2Lower = word2.toLowerCase() + if (word1Lower.length !== word2Lower.length) { + return false; +} +var string1 = word1Lower.split('').sort().join(''); +var string2 = word2Lower.split('').sort().join(''); + +var result = (string1 === string2); +return result; +} From 4596cd6d5833ff1a6978c677a934a730bbcafad8 Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Wed, 2 Nov 2022 13:18:05 -0300 Subject: [PATCH 09/11] =?UTF-8?q?feat(mostUsedChar):=20map=20esta=20retorn?= =?UTF-8?q?ando=20todas=20as=20letras=20com=20suas=20respectivas=20vezes?= =?UTF-8?q?=20que=20se=20repetem,=20n=C3=A3o=20funcional=20nos=20testes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 09-mostRepeatedChar/index.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..c7a2eb3 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,19 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" -} \ No newline at end of file + // implementar logica aqui + + const map = new Map(); + + // Percorre as letras do texto + for (let letter of text) { + + // Busca a quantidade de vezes que a letra já se repetiu, ou 0 para a primeira ocorrência + let count = map.get(letter) || 0; + + // Atualiza a frequência incrementando-a + map.set(letter, count+1) + + console.log(map) + + } + + } \ No newline at end of file From 1acd1d9c07f573cbed00b49e14dcc1be544e482a Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Wed, 2 Nov 2022 15:16:08 -0300 Subject: [PATCH 10/11] =?UTF-8?q?feat(longestWords):=20la=C3=A7o=20com=20i?= =?UTF-8?q?f=20condicional=20para=20verifica=C3=A7=C3=A3o=20do=20length=20?= =?UTF-8?q?das=20palavras?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..5a0b288 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,11 @@ export function longestWords(words) { // implementar logica aqui - -} \ No newline at end of file + let longest = ''; + for (let word of words) { + if (word.length > longest.length) { + longest = word; + } + } + + return words.filter((word) => word.length === longest.length); + } From ccc77a00ddbf35c89f7bc6ffa2abb0f792526bee Mon Sep 17 00:00:00 2001 From: Ramon Dias Ferreira Date: Wed, 2 Nov 2022 16:39:30 -0300 Subject: [PATCH 11/11] =?UTF-8?q?refactor(mostUsedChar):=20codigo=20com=20?= =?UTF-8?q?logica=20toda=20refeita.=20Tendo=20como=20principais=20fun?= =?UTF-8?q?=C3=A7=C3=B5es=20split,=20forEach=20e=20o=20if.=20funcional=20e?= =?UTF-8?q?m=20todos=20os=20testes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 09-mostRepeatedChar/index.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index c7a2eb3..e95466a 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,19 +1,11 @@ export function mostUsedChar(text) { - // implementar logica aqui - - const map = new Map(); - - // Percorre as letras do texto - for (let letter of text) { - - // Busca a quantidade de vezes que a letra já se repetiu, ou 0 para a primeira ocorrência - let count = map.get(letter) || 0; - - // Atualiza a frequência incrementando-a - map.set(letter, count+1) - - console.log(map) - - } - - } \ No newline at end of file + let max = 0, + maxChar = ''; + text.split('').forEach(function(char){ + if(text.split(char).length > max) { + max = text.split(char).length; + maxChar = char; + } + }); + return maxChar; +} \ No newline at end of file