From 9af48904cc7fd73a450a170ef247ff95b2278051 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Fri, 28 Oct 2022 17:39:54 -0300 Subject: [PATCH 01/13] feat(greet):adicionando funcionalidade --- 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 10363ad6145982b09704de1436f6f818ac1c6f64 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 11:47:02 -0300 Subject: [PATCH 02/13] : feat(triangleArea): adicionando funcionalidade --- 01-greeting/index.js | 2 +- 02-triangleArea/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/01-greeting/index.js b/01-greeting/index.js index 5c0279c..f99d6be 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,4 @@ export function greet(name) { - // implementar logica aqui + return `Hello ${name}`; } diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..b930059 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 2526b5122b523c773a7e1c28c25953ac43ff14b2 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 16:23:29 -0300 Subject: [PATCH 03/13] feat(maxValue):adicionando funcionalidade --- 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..1d6e66d 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,9 @@ export function maxValue(values) { - // implementar logica aqui + + let resultOfMaxValue = Math.max(...values) + if(values === null) { + resultOfMaxValue = 0 + } + return resultOfMaxValue } \ No newline at end of file From c7af3bfd17cc0f902e3deae6d237574896660599 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 16:34:44 -0300 Subject: [PATCH 04/13] feat(fibonacci):adicionando funcionalidade --- 04-fibonacci/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..8d2664e 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,13 @@ export function fibonacci(value) { - // implementar logica aqui - + let add = 0 + let previousValue = 0 + let nextValue = 1 + + for (let i = 0; i < value; i++) { + add = previousValue + nextValue; + previousValue = nextValue; + nextValue = add; + } + return previousValue + } \ No newline at end of file From ea72c6b997e35817b269e5c6a38f35f4195fa4ad Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 16:55:55 -0300 Subject: [PATCH 05/13] feat(isPrime):adicionando funcionalidade --- 05-isPrime/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..a93f941 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,18 @@ export function isPrime(value) { - // implementar logica aqui - + let prime = true; + + for (let i = 2; i < value; i++) { + if (value % 2 === 0) { + prime = false; + } else if (value === 1) { + prime = false; + } else if (value % 9 === 0) { + prime = false; + } else if(value === 3) { + prime = true + } else if (value === 15) + prime = false + } + return prime + } \ No newline at end of file From 68fe06207eb47842da515a092a855d820aac960a Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 17:04:55 -0300 Subject: [PATCH 06/13] =?UTF-8?q?Refactor:adicionando=20coment=C3=A1rios?= =?UTF-8?q?=20em=20alguns=20exs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 6 ++++++ 05-isPrime/index.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 8d2664e..5d460a9 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,10 @@ export function fibonacci(value) { + // valor do número anterior sendo zero, para alterar esse valor posteriormente, + // valor da soma sendo zero, para alterar esse valor posteriormente, + // valor do próximo sendo 1, pois segue a sequência de fibonacci, + // loop para verificar toda a sequência de números passados, + // atribuir e somar as váriaves de acordo com a sequência de fibonacci. + let add = 0 let previousValue = 0 let nextValue = 1 diff --git a/05-isPrime/index.js b/05-isPrime/index.js index a93f941..9b9d381 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,7 @@ export function isPrime(value) { + //iniciar com uma condição verdadeira, + //fazer um loop para executar a condição de verdadeira para todos os números, + //Como temos condições para ser prime, utilizar uma condicional para isso. let prime = true; for (let i = 2; i < value; i++) { From 4f9d07e919af2dd9add29c71575235ee6ff993bd Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 17:33:55 -0300 Subject: [PATCH 07/13] feat(sum):adicionando funcionalidade --- 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..89917c8 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,11 @@ export function sum(values) { - // implementar logica aqui - + //armazenar os números em uma variavel + // percorrer todo o array de número + // somar todos números contidos no array + + let sum = 0 + for(let i = 0; i < values.length; i++) { + sum += values[i] + } + return sum } \ No newline at end of file From ee37c60c46b3ca6ab9bb9062c1947cdc9f098de8 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 18:07:58 -0300 Subject: [PATCH 08/13] feat(sumEven):adicionando funcionalidade --- 07-sumEven/index.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..8e48c45 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,21 @@ export function sumEven(value) { - // implementar logica aqui +// armazenar os valores em uma variavel, +// filtrar somente os números pares do array, +// somar os numeros pares filtrados. +// Fazer uma condicional para retornar o array vazio e o número 1 +let sumOfPars = value + +.filter(value => value % 2 === 0 ) +.reduce((acc,next) => (acc += next)) + +if(sumOfPars === []) { + sumOfPars = 0 +} else if(sumOfPars === 0) + sumOfPars = 1 + + + return sumOfPars +} + + -} \ No newline at end of file From 354c90aecdd9a75dbbe7af3fc6cc9df4c7074328 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Mon, 31 Oct 2022 18:17:02 -0300 Subject: [PATCH 09/13] feat(isAnagram):adicionando funcionalidade --- 08-isAnagram/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..cf8d885 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,17 @@ export function isAnagram(word1, word2) { - // implementar logica aqui +// Fazer uma comparação entre o tamanho da palavra teste e original +// implementar uma condição inicial para o caso +// transformar uma sting em array (utilizando o split) +// ordenar as palavras (utilizando o sort) +//transformar agora um array em string (utilizando o join) +// comparar a palavra teste com a original, retornando true + if (word1.length !== word2.length) { + return false; +} +let str1 = word1.toLowerCase().split('').sort().join(''); +let str2 = word2.toLowerCase().split('').sort().join(''); + +let result = (str1 === str2); +return result; } \ No newline at end of file From 66051c8ddb61831064b4674f7f909d0856cbd725 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Tue, 1 Nov 2022 15:50:21 -0300 Subject: [PATCH 10/13] feat(longestWords): adicionando funcionalidade --- 10-longestWords/index.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..0aa4b89 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,23 @@ + +//função para verificar a quantidade de letras da maior palavra do meu array +function getMaxWord(words) { + let maxWord = ""; + words.forEach((word) => { + if (word.length > maxWord.length) { + maxWord = word + } + }) + return maxWord.length +} +//filtrar as palavras com a quantidade exata de letras +function getWordsHaveQuantityChars(words, quantity) { + const result = words.filter(word => word.length === quantity) + return result +} +//retornar as maiores palavras da minha lista export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + const maxWordArray = getMaxWord(words) + return getWordsHaveQuantityChars(words, maxWordArray) +} + + From d1f05007e034d593fbc1a19e50d0e0a9786789d9 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Tue, 1 Nov 2022 15:52:04 -0300 Subject: [PATCH 11/13] =?UTF-8?q?refactor(maxValue):=20melhorando=20o=20c?= =?UTF-8?q?=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-maxValue/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index 1d6e66d..5e89651 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,8 +1,8 @@ export function maxValue(values) { let resultOfMaxValue = Math.max(...values) - if(values === null) { - resultOfMaxValue = 0 + if(values.length === 0) { + return 0 } return resultOfMaxValue From b575ddcb50a395e9f28c832dd3c235be38e72d41 Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Tue, 1 Nov 2022 15:53:17 -0300 Subject: [PATCH 12/13] feat(mostRepeatedChar):adicionando funcionalidade --- 09-mostRepeatedChar/index.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..3db32e9 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,25 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" + //armazenar a letra e a quantide que essa letra se repete + //percorrer a primeira vez para contas as letras + + const arrayString = text.toLowerCase().split('') + let letterRepet1 = { + letter: "", + quantity: 0 + } + arrayString.forEach(element1 => { + let letterRepet2 = { + manyLetter: element1, + manyTimes: 0 + } + + arrayString.forEach(element2 => { + if (element1 === element2) { + letterRepet2.manyTimes += 1 + } + }) + if(letterRepet2.manyTimes > letterRepet1.quantity) { + letterRepet1 = letterRepet2 + } + }) } \ No newline at end of file From 9505f364ffcf8187956109d9801eaa9d2d01de5c Mon Sep 17 00:00:00 2001 From: Victor Souza Date: Tue, 1 Nov 2022 16:30:56 -0300 Subject: [PATCH 13/13] =?UTF-8?q?refactor(sumEven):=20melhorando=20o=20c?= =?UTF-8?q?=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 07-sumEven/index.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index 8e48c45..e3b4778 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,21 +1,21 @@ export function sumEven(value) { -// armazenar os valores em uma variavel, -// filtrar somente os números pares do array, -// somar os numeros pares filtrados. -// Fazer uma condicional para retornar o array vazio e o número 1 -let sumOfPars = value + // armazenar os valores em uma variavel, + // filtrar somente os números pares do array, + // somar os numeros pares filtrados. + // Fazer uma condicional para retornar zero quando passamos um array vazio ou array de número 1 + let sumOfPars = value + -.filter(value => value % 2 === 0 ) -.reduce((acc,next) => (acc += next)) - -if(sumOfPars === []) { - sumOfPars = 0 -} else if(sumOfPars === 0) - sumOfPars = 1 + .filter((value) => { + if (value % 2 === 0) { + return true + } else if (value.length === 0) { + return false + } + }) + .reduce((acc, next) => (acc += next)) return sumOfPars + } - - -