From ae7051e762591922bda897dc1626413f613cd5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 08:05:01 -0300 Subject: [PATCH 01/10] feat: resolve 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..203e5a7 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 f7f8e82a2169ab4e115b8e324465e93b4dee2226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 08:08:39 -0300 Subject: [PATCH 02/10] feat: resolve 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..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 31a926baf20050ad503be0774f87498eefe11eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 08:19:41 -0300 Subject: [PATCH 03/10] feat: resolve maxValue --- 03-maxValue/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..beb3856 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 -- 2.34.1 From 10b8f2fd451129b8df17b3f5b559a4c742a5d95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 08:42:28 -0300 Subject: [PATCH 04/10] feat: resolve fibonacci --- 04-fibonacci/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..1959a9a 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,15 @@ export function fibonacci(value) { // implementar logica aqui + let val1 = 0 + let val2 = 1 + let valFib + + for (let i = 1; i <= value; i++){ + valFib = val2 + val1 + val1 = val2 + val2 = valFib + } + + return val1 } \ No newline at end of file -- 2.34.1 From 0cd09a0455974b86be57958f41e454785d204cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 08:45:59 -0300 Subject: [PATCH 05/10] feat: resolve isPrime --- 05-isPrime/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..847c6e0 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,11 @@ export function isPrime(value) { // implementar logica aqui + if (value < 2 ) return false + for (let i = 2; i < value; i++) { + if (value % i == 0) { + return false; + } + } + return true; } \ No newline at end of file -- 2.34.1 From 2089a826160ff8637dd75a29ce43bdde349e0792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 08:49:07 -0300 Subject: [PATCH 06/10] feat: resolve sum --- 06-sum/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..6d311be 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,9 @@ export function sum(values) { // implementar logica aqui - + let sumArr = 0 + for (let i = 0; i < values.length; i++){ + sumArr += values[i]; + } + return sumArr; + } \ No newline at end of file -- 2.34.1 From e856d29e724b561ae89f7f50690bb3b0332a395f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 08:52:36 -0300 Subject: [PATCH 07/10] feat: resolve sumEven --- 07-sumEven/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..8c170c4 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,11 @@ export function sumEven(value) { // implementar logica aqui - + let sumPair = 0 + for (let i = 0; i < value.length; i++){ + if (value[i] % 2 == 0){ + sumPair += value[i]; + } + } + return sumPair; + } \ No newline at end of file -- 2.34.1 From e50b6fb5ae103a042eaa5cbbf55e41594bc83781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 08:57:56 -0300 Subject: [PATCH 08/10] feat: resole isAnagram --- 08-isAnagram/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..2898bf9 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,4 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + return word1.toLowerCase().split("").sort().join("") === word2.toLowerCase().split("").sort().join(""); } \ No newline at end of file -- 2.34.1 From d68e3bd4d9cd5549c7e58154c818753b697748fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 09:28:53 -0300 Subject: [PATCH 09/10] feat: resolve mostRepeatedChar --- 09-mostRepeatedChar/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..7bd559b 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,13 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + const arr = text.split(""); + + let timesRepeat = {}; + arr.forEach((count) => { + timesRepeat[count] = (timesRepeat[count] || 0) + 1; + }) + + const maxVal = Math.max(...Object.values(timesRepeat)); + const num = Object.keys(timesRepeat).find((key) => timesRepeat[key] === maxVal); + return num; } \ No newline at end of file -- 2.34.1 From 9efc45556522af09274188b6299608974c82190b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naian=20F=C3=A9lix?= Date: Fri, 28 Oct 2022 10:51:39 -0300 Subject: [PATCH 10/10] feat: resolve longestWords --- 10-longestWords/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..9f9607f 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,18 @@ export function longestWords(words) { // implementar logica aqui + let big = ""; + words.forEach(word => { + if(word.length > big.length){ + big = word + } + }); + + const result = words.filter(word => { + if(word.length === big.length){ + return word + } + }); + + return result } \ No newline at end of file -- 2.34.1