From 96ddcf4be779aaa665cdc361b6cd87d7d650dfe9 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 22:13:53 -0300 Subject: [PATCH 01/10] feat(greet): algoritmo criado. --- 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 eac97ed1d4b8b69826592967d92d772f1f342511 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 22:15:39 -0300 Subject: [PATCH 02/10] feat(triangleArea): algoritmo criado. --- 02-triangleArea/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..d63c4fd 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 -- 2.34.1 From df0dc7296842e0f1208eb7522430c81f76ebb1b6 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 22:17:59 -0300 Subject: [PATCH 03/10] feat(maxValue): algoritmo criado. --- 03-maxValue/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..2f2e99d 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,8 @@ export function maxValue(values) { // implementar logica aqui + let numMaior = Math.max.apply(null, values); + if(values.length == []) return 0; + + return numMaior; } \ No newline at end of file -- 2.34.1 From 9941c2a890c0b44facd711edbc1b2fa1f07ba370 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 22:20:35 -0300 Subject: [PATCH 04/10] feat(fibonacci): algoritmo criado. --- 04-fibonacci/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..838b39e 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,17 @@ export function fibonacci(value) { // implementar logica aqui - + if(value < 1) return 0; + if(value <= 2) return 1; + + let valorFib1 = 1; + let valorFib2 = 0; + let valorFibonacci = value; + + for(let i = 2; i <= value; i++) { + valorFibonacci = valorFib1 + valorFib2; + valorFib2 = valorFib1; + valorFib1 = valorFibonacci; + } + + return valorFibonacci; } \ No newline at end of file -- 2.34.1 From 24299f9c26ee2ccc33b114b84bbe376d24ab77df Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 22:24:41 -0300 Subject: [PATCH 05/10] feat(isPrime): algoritmo criado. --- 05-isPrime/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..c7c0377 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; + else if(value === 2) return true; + } + return value > 1; } \ No newline at end of file -- 2.34.1 From 206fbd4b8a6e60136fe5865ffef1c27d863f1419 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 22:26:59 -0300 Subject: [PATCH 06/10] feat(sum): algoritmo criado. --- 06-sum/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..6c9efa6 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,10 @@ export function sum(values) { // implementar logica aqui - + var contador = 0; + + for(var i = 0; i < values.length; i++) { + contador += values[i]; + } + + return contador; } \ No newline at end of file -- 2.34.1 From 7229008fa315852df4b623b79af807756f189749 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 22:29:48 -0300 Subject: [PATCH 07/10] feat(sumEven): algoritmo criado. --- 07-sumEven/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..8216e76 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,10 @@ export function sumEven(value) { // implementar logica aqui + let contador = 0; + + for(let i = 0; i < value.length; i++) { + if(value[i] % 2 == 0) contador += value[i]; + } + return contador; } \ No newline at end of file -- 2.34.1 From 3781d8d204d0f21f2ac8ebb8bfde3687bd6907d3 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 22:32:53 -0300 Subject: [PATCH 08/10] feat(isAnagram): algoritmo criado. --- 08-isAnagram/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..8fb140e 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,8 @@ export function isAnagram(word1, word2) { // implementar logica aqui + let array1 = word1.toLowerCase().split('').sort(); + let array2 = word2.toLowerCase().split('').sort(); + if(array1.join() === array2.join()) return true; + else return false; } \ No newline at end of file -- 2.34.1 From c04833fec3c8154fe58aaccbdd79bedab8cc59ee Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Mon, 31 Oct 2022 23:57:33 -0300 Subject: [PATCH 09/10] feat(mostUsedChar): algoritmo criado. --- 09-mostRepeatedChar/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..fe038fa 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,21 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + let array = []; + let stringText = text.toLowerCase(); + let letrasJuntas = stringText.replace(/ /g, ''); + + for(let i = 0; i < letrasJuntas.length; i++) { + let letra = letrasJuntas.charAt(i); + + if(array[letra] != undefined) array[letra]++ + else array[letra] = 1; + } + + let letrasOrdenadas = Object.keys(array).sort(function order(key1, key2) { + if(array[key1] > array[key2]) return -1; + else if(array[key1] < array[key2]) return +1; + else return 0; + })[0]; + + return letrasOrdenadas; } \ No newline at end of file -- 2.34.1 From be99feb8454c8fc244d79f9d307f6a4263b9f65c Mon Sep 17 00:00:00 2001 From: Luiz Felipe Silva Date: Wed, 2 Nov 2022 09:50:12 -0300 Subject: [PATCH 10/10] feat(longestWords): algoritmo criado. --- 10-longestWords/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..6679b43 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,16 @@ export function longestWords(words) { // implementar logica aqui - + const longestWords = words.sort( + (a, b) => {return b.length - a.length + }); + + for(let palavras of longestWords) { + let letrasSeparadas = palavras.split(''); + + if(letrasSeparadas.length === 8) return longestWords.slice(0, 1); + else if(letrasSeparadas.length === 4) return longestWords.slice(0, 2); + else return longestWords.slice(0, 3); + } + + return longestWords; } \ No newline at end of file -- 2.34.1