From e2ba3072be5e009bf4faca592061354c6f5ceb72 Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 15:49:03 -0300 Subject: [PATCH 01/10] feat(greeting): adiciona resolucao questao01-greeting --- 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 c9dafce572e66469c1e1226b5e3d306f450c1bae Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 15:51:18 -0300 Subject: [PATCH 02/10] feat(triangleArea): adiciona resolucao questao02-triangleArea --- 02-triangleArea/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..85ffa32 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 4af6fcb6bf77800a1395fd2f0474570ae62bf035 Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 15:56:15 -0300 Subject: [PATCH 03/10] feat(maxValue): adiciona resolucao questao03-maxValue --- 03-maxValue/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..7539ea0 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,6 @@ export function maxValue(values) { // implementar logica aqui - + if(Math.max.apply(undefined ,values) == -Infinity) + return 0 + return Math.max.apply(undefined ,values); } \ No newline at end of file From 882a6b02d64b37184d60b7d5d6235d77e1943276 Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 15:58:51 -0300 Subject: [PATCH 04/10] feat(fibonacci): adiciona resolucao questao04-fibonacci --- 04-fibonacci/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..f3dd52e 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,8 @@ export function fibonacci(value) { // implementar logica aqui - + const arr = [0, 1]; + for (let i = 2; i <= value; i++) { + arr[i] = arr[i - 2] + arr[i - 1]; + } + return arr[value]; } \ No newline at end of file From 117127ae3827a6b91d6171591c2c5204a71fa25e Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 16:02:38 -0300 Subject: [PATCH 05/10] feat(isPrime): adiciona resolucao questao05-isprime --- 05-isPrime/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..6e7afa2 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,11 @@ export function isPrime(value) { // implementar logica aqui - + if (isNaN(value) || !isFinite(value) || value % 1 || value < 2) + return false; + if (value % 2 == 0) + return (value == 2); + for (let i = 3; i <= Math.sqrt(value); i += 2) { + if (value % i == 0) return false; + } + return true; } \ No newline at end of file From 309e130fd55eedc9544cb4746291bdac7ad79893 Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 16:07:47 -0300 Subject: [PATCH 06/10] feat(sum):adiciona resolucao questao06-sum --- 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..5a27c2f 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,8 @@ export function sum(values) { // implementar logica aqui - + let res=0; + values.forEach(element => { + res+=element; + }); + return res; } \ No newline at end of file From 2e4a5caf0a3a6752685646aa1b2fd7778796899f Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 16:10:35 -0300 Subject: [PATCH 07/10] feat(sumEven): adiciona resolucao questao07-sumeven --- 07-sumEven/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..97c648c 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,9 @@ export function sumEven(value) { // implementar logica aqui - + let res=0; + value.forEach(element => { + if(element % 2 === 0) + res+=element; + }); + return res; } \ No newline at end of file From b22aa4bde7bcefeabaede8a07f0d93d4c917b64a Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 16:12:56 -0300 Subject: [PATCH 08/10] feat(isAnagram): adiciona resolucao questao08-isanagram --- 08-isAnagram/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..a8d08f0 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,6 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + if (word1.toLowerCase().split('').sort().join('')===word2.toLowerCase().split('').sort().join('')) + return true + return false } \ No newline at end of file From e4e94adf5ef9f57d0769632d943aa5e376f2f1aa Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 16:16:15 -0300 Subject: [PATCH 09/10] feat(mostRepeatedChar): adiciona resolucao questao09-mostrepeatedchar --- 09-mostRepeatedChar/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..af729cd 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,12 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + let max = 0; + let maxRepeated = ''; + text.split('').forEach(function(char){ + if(text.split(char).length > max) { + max = text.split(char).length; + maxRepeated = char; + } + }); + return maxRepeated; } \ No newline at end of file From aec9c86d4907d39d28a94060d87908200f2417ad Mon Sep 17 00:00:00 2001 From: carloswinter Date: Fri, 28 Oct 2022 16:19:30 -0300 Subject: [PATCH 10/10] feat(longestWords): adiciona resolucao questao10-longestwords --- 10-longestWords/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..d17f723 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,14 @@ export function longestWords(words) { // implementar logica aqui - + let newArr = []; + let long = 0; + words.forEach(function(element){ + if(element.length > long){ + long = element.length + } + }); + newArr = words.filter(element => + element.length == long + ); + return newArr; } \ No newline at end of file