From 3ad3c1aa8d7157e1e1c29206c49e92b9672fa984 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Fri, 28 Oct 2022 12:33:09 -0300 Subject: [PATCH 01/11] feat(Greeting): finaliza algoritmo --- 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 b7e0d17d1e54f7561dd3b638718a2f6e8c41fcbb Mon Sep 17 00:00:00 2001 From: WillSimao Date: Fri, 28 Oct 2022 12:44:05 -0300 Subject: [PATCH 02/11] feat(triangleArea): Finaliza algoritmo --- 02-triangleArea/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..bc6458b 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 59ff8f2a54e9a436ca4b2a7fd5a2237ffa039871 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Fri, 28 Oct 2022 12:51:03 -0300 Subject: [PATCH 03/11] feat(maxValue): Finaliza algoritmo --- 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..daba193 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 values.length; + } + + return Math.max(...values) } \ No newline at end of file From 88401e325504b5c1d92a08ec1121a6cd173cd5f9 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Fri, 28 Oct 2022 13:13:32 -0300 Subject: [PATCH 04/11] feat(fibonacci): Finaliza algoritmo --- 04-fibonacci/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..4c85a16 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,16 @@ export function fibonacci(value) { // implementar logica aqui + let soma = 0; + let anterior = 0; + let proximo = 1; + + for (let i = 0; i < value; i++) { + soma = anterior + proximo; + anterior = proximo; + proximo = soma; + } + + return anterior; + } \ No newline at end of file From c26a87b84309607778d19c12413b51486e48a313 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Fri, 28 Oct 2022 14:06:18 -0300 Subject: [PATCH 05/11] feat(isPrime): Finaliza algoritmo --- 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..5c8f71f 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 > 1; } \ No newline at end of file From f748d31ad5c75ea07692cb4f49431844aba16862 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Sat, 29 Oct 2022 02:05:24 -0300 Subject: [PATCH 06/11] feat(isAnagram): Finaliza algoritmo --- 08-isAnagram/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..6c9c73a 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,16 @@ export function isAnagram(word1, word2) { // implementar logica aqui + + const word2Arr = word2.toLowerCase().split(''); + + for(let i = 0; i < word1.length; i++) { + + const index = word2Arr.indexOf(word1.toLowerCase()[i]); + + if(index === -1) return false; + word2Arr.splice(index, 1); + } + + return !word2Arr.length; } \ No newline at end of file From e3124dd467807393d7861c533d2f75a0619bcf1a Mon Sep 17 00:00:00 2001 From: WillSimao Date: Sat, 29 Oct 2022 07:42:54 -0300 Subject: [PATCH 07/11] feat(sum): Finaliza algoritmo --- 06-sum/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..4c0b742 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,4 @@ export function sum(values) { // implementar logica aqui - + return values.reduce((firstValue, secondValue) => firstValue + secondValue, 0) } \ No newline at end of file From 5f27101ce75c919299db369710f70a8bcf126847 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Sat, 29 Oct 2022 07:46:34 -0300 Subject: [PATCH 08/11] feat(sumEven): Finaliza algoritmo --- 07-sumEven/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..07242a3 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,12 @@ 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 eac3bbdc0a85e1fdf0d0c9d9b3c460e804d54946 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Sat, 29 Oct 2022 20:28:35 -0300 Subject: [PATCH 09/11] feat(isAnagram): Finaliza algoritmo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Estou reutilizando esse algoritmo, do meu projeto antigo, provisóriamente pois acredito que não estou usando boas práticas --- 08-isAnagram/index.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 6c9c73a..98f98ff 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,16 +1,6 @@ export function isAnagram(word1, word2) { // implementar logica aqui - - const word2Arr = word2.toLowerCase().split(''); - - for(let i = 0; i < word1.length; i++) { - - const index = word2Arr.indexOf(word1.toLowerCase()[i]); - - if(index === -1) return false; - word2Arr.splice(index, 1); - } - - return !word2Arr.length; - -} \ No newline at end of file + return word1.toLowerCase().split("").sort().join() === word2.toLowerCase().split("").sort().join(); + + + } From e9f6faa98899dcc9bcbbcb0166868894c01ad9b7 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Mon, 31 Oct 2022 10:27:30 -0300 Subject: [PATCH 10/11] feat(monstUsedChar): Finaliza algoritmo --- 09-mostRepeatedChar/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..87367f7 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,17 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + + let max = 0; + let maxCaracter = ""; + + text.split('').forEach((caracter) => { + if (text.split(caracter).length > max) { + max = text.split(caracter).length; + + maxCaracter = caracter; + } + }); + + + return maxCaracter; } \ No newline at end of file From c7e515ec35d0acb01c048832b24d5c7a1e935213 Mon Sep 17 00:00:00 2001 From: WillSimao Date: Mon, 31 Oct 2022 16:55:29 -0300 Subject: [PATCH 11/11] feat(longestWords): Finaliza algoritmo --- 10-longestWords/index.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..9134806 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,26 @@ export function longestWords(words) { // implementar logica aqui - -} \ No newline at end of file + + let longestLength = 0; + let longestWords = []; + + words.forEach(word => { + if (longestLength < word.length) { + longestLength = word.length; + } else { + longestLength; + } + + }); + + words.forEach(word => { + if (word.length === longestLength) { + longestWords.push(word); + } + }); + + return longestWords; + } + + +