From 7cca2388da3c2eca5970b4674df85b884d00fe9c Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 20:08:02 -0300 Subject: [PATCH 01/10] feat(challenge-1): completed challenge --- 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 529b692747e606bfe34209aa06884434f7108698 Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 20:41:22 -0300 Subject: [PATCH 02/10] feat(challenge-2): completed challenge --- 02-triangleArea/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..4deaa85 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,6 @@ -export function triangleArea(base, height) { +export function triangleArea(base, height) { // your code here -} \ No newline at end of file + if (!base || !height) return 0; + + return (base * height) / 2; +} -- 2.34.1 From 91b726984053d2e662c38206c1aa83c61d87a41a Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 20:44:51 -0300 Subject: [PATCH 03/10] feat(challenge-3): completed challenge --- 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..a8ec540 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,6 @@ export function maxValue(values) { // implementar logica aqui - + if(values.length === 0 || !values) return 0 + + return Math.max(...values) } \ No newline at end of file -- 2.34.1 From dbbbb6c4c6a0da5448536997d88fdfd6309044d7 Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 20:51:29 -0300 Subject: [PATCH 04/10] feat(challenge-4): completed challenge --- 04-fibonacci/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..ef73b48 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,16 @@ export function fibonacci(value) { // implementar logica aqui - -} \ No newline at end of file + if (!value) return 0; + + let n1 = 0, + n2 = 1, + nextTerm; + + for (let i = 1; i <= value; i++) { + nextTerm = n1 + n2; + n1 = n2; + n2 = nextTerm; + } + + return n1; +} -- 2.34.1 From 1b584da7b21cab2956faefcce4350da001425e4f Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 20:58:33 -0300 Subject: [PATCH 05/10] feat(challenge-5): completed challenge --- 05-isPrime/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..397ac79 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,12 @@ export function isPrime(value) { // implementar logica aqui - -} \ No newline at end of file + if (!value) return 0; + + for(let i = 2; i < value; i++){ + if(value % i === 0){ + return false + } + } + + return true +} -- 2.34.1 From e9fc82de974f30db6d18034ae516dea6526b716a Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 21:03:44 -0300 Subject: [PATCH 06/10] feat(challenge-6): completed challenge --- 06-sum/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..8d606f2 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,9 @@ export function sum(values) { // implementar logica aqui - -} \ No newline at end of file + if (values.length === 0 || !values) return 0; + + // acc é abreviação de accumulator(acumulador) + return values.reduce((acc, number) => { + return (acc += number); + }, 0); +} -- 2.34.1 From 8d7b786b23576dcd7a07450d198b148130a691db Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 21:12:10 -0300 Subject: [PATCH 07/10] feat(challenge-7): completed challenge --- 07-sumEven/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..a850424 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,13 @@ export function sumEven(value) { // implementar logica aqui - -} \ No newline at end of file + if (value.length === 0 || !value) return 0; + + // acc é abreviação de accumulator(acumulador) + return value.reduce((acc, number) => { + if (number % 2 === 0) { + return (acc += number); + }else { + return acc += 0 + } + }, 0); +} -- 2.34.1 From 29ec105dd312ba1f1fee6694cbbf8ca2448392eb Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 21:22:41 -0300 Subject: [PATCH 08/10] feat(challenge-8): completed challenge --- 08-isAnagram/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..4648e7b 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,18 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + if (!word1 || !word2) return { error: 'Not Found Words' }; + + function toLowerCase(word) { + return word.toLowerCase(); + } + + function toSortWord(word) { + return word.split('').sort().join(''); + } + + function toAnalyzing(word){ + return toSortWord(toLowerCase(word)) + } + + return toAnalyzing(word1) === toAnalyzing(word2) +} -- 2.34.1 From 6801fc069d56cc9a5425b7483005fbe8105005cf Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 21:35:13 -0300 Subject: [PATCH 09/10] feat(challenge-9): completed challenge --- 09-mostRepeatedChar/index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..28f1041 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,15 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" -} \ No newline at end of file + if (!text) return { error: 'Not Found Text' }; + + let max = 0, + maxChar = ''; + + for (let char of text) { + if (text.split(char).length > max) { + max = text.split(char).length; + maxChar = char; + } + } + + return maxChar; +} -- 2.34.1 From ecf880dc2fc12273f41cf1a175f6de5ae6e7049e Mon Sep 17 00:00:00 2001 From: HenriqueSSan Date: Thu, 27 Oct 2022 22:01:20 -0300 Subject: [PATCH 10/10] feat(challenge-10): completed challenge --- 10-longestWords/index.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..2153892 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,21 @@ export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + // implementar logica aqui + if (words.length === 0 || !words) return 0; + + let wordLengthMax = 0; + let wordsList = []; + + for (let word of words) { + if (word.length >= wordLengthMax) { + wordLengthMax = word.length; + } + } + + for (let word of words) { + if (wordLengthMax === word.length) { + wordsList.push(word); + } + } + + return wordsList; +} -- 2.34.1