From 1e61b5ddd8378c11572d22f7b342746998e01a00 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 06:44:42 -0400 Subject: [PATCH 01/12] =?UTF-8?q?feat(greet):=20fazendo=20func=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..c1211f1 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 8a8712c9ae1b751e0574c6d17caaac76fd4cfa8e Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:33:29 -0400 Subject: [PATCH 02/12] =?UTF-8?q?refactor(greet):=20melhorando=20c=C3=B3di?= =?UTF-8?q?go=20func=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 c1211f1..5c0279c 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,4 @@ export function greet(name) { // implementar logica aqui - return "Hello " + name; + return `Hello ${name}`; } From 2aac0d168b150e55c37fa977e0559280392101fb Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:34:26 -0400 Subject: [PATCH 03/12] =?UTF-8?q?feat(triangleArea):=20fazendo=20func?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-triangleArea/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..d54f939 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,3 @@ -export function triangleArea(base, height) { - // your code here -} \ No newline at end of file +export function triangleArea(base, height) { + return (base * height) / 2; +} From 7536d3d99d52d71311037010bcfd5a1016891d0d Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:35:13 -0400 Subject: [PATCH 04/12] =?UTF-8?q?feat(maxValue):=20fazendo=20func=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-maxValue/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..c47fa02 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,11 @@ export function maxValue(values) { // implementar logica aqui - -} \ No newline at end of file + if (values != `${[]}`) { + let max = values.reduce(function (a, b) { + return Math.max(a, b); + }, -Infinity); + return max; + } else { + return 0; + } +} From 78013803519c17de224ad1bc9b27206457b2dfdf Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:36:27 -0400 Subject: [PATCH 05/12] =?UTF-8?q?feat(isPrime):=20fazendo=20func=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 05-isPrime/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..2b2b45d 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,14 @@ export function isPrime(value) { // implementar logica aqui - -} \ No newline at end of file + let divisores = 0; + for (let index = 1; index <= value; index++) { + if (value % index == 0) { + divisores++; + } + } + if (divisores == 2) { + return true; + } else { + return false; + } +} From 755ff029e8891e18cc220f196126359aac558a79 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:40:50 -0400 Subject: [PATCH 06/12] =?UTF-8?q?feat(sum):=20fazendo=20func=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 7 +++++-- 06-sum/index.js | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..f2ec99f 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,7 @@ export function fibonacci(value) { // implementar logica aqui - -} \ No newline at end of file + if (value <= `${1}`) { + return value; + } + return fibonacci(value - 1) + fibonacci(value - 2); +} diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..d071540 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,8 @@ export function sum(values) { // implementar logica aqui - -} \ No newline at end of file + function add(a, b) { + return a + b; + } + var soma = values.reduce(add, 0); + return soma; +} From b797ec9a599985f769d9aeb226d784fa72475df9 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:42:09 -0400 Subject: [PATCH 07/12] =?UTF-8?q?feat(sumEven):=20fazendo=20func=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 07-sumEven/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..2aa5e6a 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,15 @@ export function sumEven(value) { // implementar logica aqui - -} \ No newline at end of file + const arr = []; + for (let index = 0; index < value.length; index++) { + const element = value[index]; + if (element % 2 == 0) { + arr.push(element); + } + } + function add(a, b) { + return a + b; + } + var soma = arr.reduce(add, 0); + return soma; +} From 401b1cc7ac9f9c399816483ce44019f3be0d8980 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:43:43 -0400 Subject: [PATCH 08/12] =?UTF-8?q?feat(isAnagram):=20fazendo=20func=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08-isAnagram/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..46c6e30 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,14 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + if (word1.length === word2.length) { + let word1Lower = word1.toLowerCase().split("").sort(); + let word2Lower = word2.toLowerCase().split("").sort(); + if (word1Lower.join() == word2Lower.join()) { + return true; + } else { + return false; + } + } else { + return false; + } +} From 0295676121233a853fc7878556f1651b97a6c5d6 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 07:44:38 -0400 Subject: [PATCH 09/12] =?UTF-8?q?feat(mostUsedChar):=20fazendo=20func?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 09-mostRepeatedChar/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..fbde00f 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,10 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" -} \ No newline at end of file + // implementar logica aqui + let textLower = text.toLowerCase().split("").sort(); + for (let index = 1; index < textLower.length; index++) { + textLower = textLower.filter((e, i, a) => a.indexOf(e) !== i); + } + + let letter = [...new Set(textLower)]; + return letter.join(""); +} From 967448340ad8b3ff35507b3d4d919ecf3d8c3033 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 08:02:20 -0400 Subject: [PATCH 10/12] =?UTF-8?q?feat(longestWords):=20fazendo=20func?= =?UTF-8?q?=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, 16 insertions(+), 3 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..7981158 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,17 @@ export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + // implementar logica aqui + let max_string_size = 0; + let big_string_list = []; + + for (let string of words) { + const string_size = string.length; + + if (string_size > max_string_size) { + big_string_list = [string]; + max_string_size = string_size; + } else if (string_size == max_string_size) { + big_string_list.push(string); + } + } + return big_string_list; +} From 048bf70c66c47cd8a1c93ac4b1a723865ca7f7e5 Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 08:50:15 -0400 Subject: [PATCH 11/12] =?UTF-8?q?feat(fibonacci):=20fazendo=20func=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index f2ec99f..818b908 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,7 +1,18 @@ export function fibonacci(value) { // implementar logica aqui - if (value <= `${1}`) { + var penultimo = 0, + ultimo = 1; + var numero; + let arr = []; + if (value < 2) { return value; + } else { + for (var count = 2; count <= value; count++) { + numero = ultimo + penultimo; + penultimo = ultimo; + ultimo = numero; + arr.push(ultimo); + } + return arr[value - 2]; } - return fibonacci(value - 1) + fibonacci(value - 2); } From 65facdebcb011ecdc7e07cecef110e5ba96429ec Mon Sep 17 00:00:00 2001 From: Caroline Moran Date: Fri, 28 Oct 2022 08:51:31 -0400 Subject: [PATCH 12/12] fix(fibonacci): muda var para let --- 04-fibonacci/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 818b908..d3ec854 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,13 +1,13 @@ export function fibonacci(value) { // implementar logica aqui - var penultimo = 0, + let penultimo = 0, ultimo = 1; - var numero; + let numero; let arr = []; if (value < 2) { return value; } else { - for (var count = 2; count <= value; count++) { + for (let count = 2; count <= value; count++) { numero = ultimo + penultimo; penultimo = ultimo; ultimo = numero;