From 30e966ba4e87f151be677a140ff29332ba97c3f3 Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sat, 29 Oct 2022 12:18:18 -0300 Subject: [PATCH 01/10] =?UTF-8?q?feat(01-greeting):=20adiciona=20fun=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 2d10433ffc3d526b4138ce9fbe02620347ef2fc4 Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sat, 29 Oct 2022 12:36:01 -0300 Subject: [PATCH 02/10] =?UTF-8?q?feat(02-triangleArea):=20Adiciona=20fun?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-triangleArea/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..2e2feba 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,3 @@ export function triangleArea(base, height) { - // your code here + return (base * height) / 2 } \ No newline at end of file From 6c1bf006f4c9b53135add4bb6831a24260ec014f Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sat, 29 Oct 2022 13:02:24 -0300 Subject: [PATCH 03/10] =?UTF-8?q?feat(03-maxValue):=20Adiciona=20fun=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-maxValue/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..196773d 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,5 @@ export function maxValue(values) { // implementar logica aqui - + if (values.length === 0) return 0; + return Math.max.apply(null, values); } \ No newline at end of file From 6abc22ea8eb2c0dfc8ba71d219a689e1f5daa9e2 Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sat, 29 Oct 2022 14:00:04 -0300 Subject: [PATCH 04/10] =?UTF-8?q?feat(04-fibonacci):=20Adiciona=20fun?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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..c16fc61 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,8 @@ export function fibonacci(value) { // implementar logica aqui - + if (value === 0 || value === 1) { + return value; + } else { + return fibonacci(value - 1) + fibonacci(value - 2); + } } \ No newline at end of file From 209e6ee2aa0d3c3363add4fc7e6e1c589f320e9b Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sat, 29 Oct 2022 14:16:32 -0300 Subject: [PATCH 05/10] =?UTF-8?q?feat(05-isPrime0:=20Adiciona=20fun=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 05-isPrime/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..44128c2 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,5 @@ export function isPrime(value) { - // implementar logica aqui - + var start = 2; + while (start <= Math.sqrt(value)) if (value % start++ < 1) return false; + return value > 1; } \ No newline at end of file From b755e428f9e79c5a21940eb1d6a54a8840326e61 Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sat, 29 Oct 2022 14:37:02 -0300 Subject: [PATCH 06/10] =?UTF-8?q?feat(06-sum):=20Adiciona=20fun=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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..23c46e3 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((acc, cur) => acc + cur, 0) } \ No newline at end of file From b74587fc2f0a87bbdbfefd52398d3b7b986c04e7 Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sat, 29 Oct 2022 17:21:49 -0300 Subject: [PATCH 07/10] =?UTF-8?q?feat(07-sumEven):=20Adiciona=20fun=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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..1233b25 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,11 @@ export function sumEven(value) { // implementar logica aqui - + if (value.length === 0) return 0; + let soma = 0; + for(let i = 0; i < value.length; i ++){ + if(value[i] % 2 === 0){ + soma = soma + value[i]; + } + } + return soma; } \ No newline at end of file From d32e6541d34810cdab0fada32736bd34c24951e3 Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sat, 29 Oct 2022 17:27:17 -0300 Subject: [PATCH 08/10] =?UTF-8?q?feat(08-isAnagram):=20Adiciona=20fun?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08-isAnagram/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..f2469ec 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,10 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + const word1LowerCase = word1.toLowerCase(); + const word2LowerCase = word2.toLowerCase(); + + const word1Sorted = word1LowerCase.split('').sort().join(''); + const word2Sorted = word2LowerCase.split('').sort().join(''); + + return word1Sorted === word2Sorted; } \ No newline at end of file From 0eecc63f1c6a5ce2649e5a51bc7792433ec984cd Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Sun, 30 Oct 2022 19:40:31 -0300 Subject: [PATCH 09/10] =?UTF-8?q?feat(09-mostRepeatedChar):=20Adiciona=20f?= =?UTF-8?q?un=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 09-mostRepeatedChar/index.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..e993202 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,23 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + const charMap = {}; + let max = 0; + let frequentChar = ''; + + for (let char of text) { + if (charMap[char]){ + charMap[char]++; + } else { + charMap[char] = 1; + } + } + + for (let char in charMap) { + if (charMap[char] > max) { + max = charMap[char]; + frequentChar = char; + } + } + + return frequentChar } \ No newline at end of file From 3c5165a3587565ca2b0fa03ea13c88e163eba702 Mon Sep 17 00:00:00 2001 From: Emerson Fully <63175980+emersonfully@users.noreply.github.com> Date: Tue, 1 Nov 2022 22:52:13 -0300 Subject: [PATCH 10/10] =?UTF-8?q?feat(10-longestWords):=20adiciona=20fun?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..d6dfaec 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,19 @@ export function longestWords(words) { // implementar logica aqui - -} \ No newline at end of file + const longestWords = []; + let longest = ''; + + for (let i = 0; i < words.length; i++) { + if (words[i].length > longest.length) { + longest = words[i]; + } + } + + for (let i = 0; i < words.length; i++) { + if (words[i].length === longest.length) { + longestWords.push(words[i]); + } + } + + return longestWords; +}