From 18e42e39082cc9160bb6d87f9530c3830d146815 Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Sun, 30 Oct 2022 21:43:34 -0300 Subject: [PATCH 01/11] feat(01,02): finished --- 01-greeting/index.js | 2 +- 02-triangleArea/index.js | 1 + 2 files changed, 2 insertions(+), 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; } 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 47142e30854c7435245b0c7a92739715fade5a83 Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Mon, 31 Oct 2022 12:45:34 -0300 Subject: [PATCH 02/11] feat(04): finished --- 03-maxValue/index.js | 2 +- 04-fibonacci/index.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..101103f 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,4 @@ export function maxValue(values) { // implementar logica aqui - + return Math.max(...values); } \ No newline at end of file diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..2823038 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,14 @@ export function fibonacci(value) { // implementar logica aqui - + if (value < 1) return 0 + if (value <= 2) return 1 + let fibMinus2 = 0 + let fibMinus1 = 1 + let fibN = value + for(let i = 2; i <= value; i++){ + fibN = fibMinus1 + fibMinus2 + fibMinus2 = fibMinus1 + fibMinus1 = fibN + } + return fibN } \ No newline at end of file -- 2.34.1 From 433eb5906de7af354d3124e513472299b3ae9729 Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Mon, 31 Oct 2022 12:45:41 -0300 Subject: [PATCH 03/11] feat(04): finished --- 04-fibonacci/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 2823038..a81a5de 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -2,13 +2,13 @@ export function fibonacci(value) { // implementar logica aqui if (value < 1) return 0 if (value <= 2) return 1 - let fibMinus2 = 0 - let fibMinus1 = 1 - let fibN = value + let fibAnterior = 0 + let fibProximo = 1 + let fibValue = value for(let i = 2; i <= value; i++){ - fibN = fibMinus1 + fibMinus2 - fibMinus2 = fibMinus1 - fibMinus1 = fibN + fibValue = fibProximo + fibAnterior + fibAnterior = fibProximo + fibProximo = fibValue } - return fibN + return fibValue } \ No newline at end of file -- 2.34.1 From 835d6452513cefc5e3d9ffc1934d259883aa478c Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Mon, 31 Oct 2022 13:15:19 -0300 Subject: [PATCH 04/11] feat(05): finished --- 05-isPrime/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..159f8cf 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,6 @@ export function isPrime(value) { // implementar logica aqui - + for (var divisão = 2; divisão < value; divisão++) + if (value % divisão == 0) return false; + return true; } \ No newline at end of file -- 2.34.1 From 82a96126a43c65ce85c9bbbda2896c85d7552d3a Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Mon, 31 Oct 2022 13:50:14 -0300 Subject: [PATCH 05/11] feat(03): finished --- 03-maxValue/index.js | 4 ++++ 06-sum/index.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index 101103f..2c7394d 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 + } return Math.max(...values); + } \ No newline at end of file diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..a278fe5 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,8 @@ export function sum(values) { // implementar logica aqui - + let soma = 0 + for (let index = 0; index < values.lenght; index += 1) { + soma = soma + values[index]; + } + return soma; } \ No newline at end of file -- 2.34.1 From d1c7f499b0cac2ed6dd74bad8f6dc45d86411b89 Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Mon, 31 Oct 2022 14:15:35 -0300 Subject: [PATCH 06/11] feat(06): finished --- 06-sum/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/06-sum/index.js b/06-sum/index.js index a278fe5..7f49509 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,8 +1,15 @@ export function sum(values) { // implementar logica aqui - let soma = 0 - for (let index = 0; index < values.lenght; index += 1) { - soma = soma + values[index]; - } - return soma; + if (toString.call(values) !== "[object Array]") + return false; + + var total = 0; + for(var i=0;i Date: Mon, 31 Oct 2022 14:43:37 -0300 Subject: [PATCH 07/11] refactor(06): deleting lines --- 06-sum/index.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/06-sum/index.js b/06-sum/index.js index 7f49509..ce8b529 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,15 +1,9 @@ export function sum(values) { // implementar logica aqui - if (toString.call(values) !== "[object Array]") - return false; - - var total = 0; - for(var i=0;i Date: Mon, 31 Oct 2022 14:55:36 -0300 Subject: [PATCH 08/11] feat(07): finished --- 05-isPrime/index.js | 2 +- 06-sum/index.js | 6 +++--- 07-sumEven/index.js | 14 +++++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index 159f8cf..4e8749b 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,6 +1,6 @@ export function isPrime(value) { // implementar logica aqui - for (var divisão = 2; divisão < value; divisão++) + for (let divisão = 2; divisão < value; divisão++) if (value % divisão == 0) return false; return true; } \ No newline at end of file diff --git a/06-sum/index.js b/06-sum/index.js index ce8b529..f3a0f55 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,9 +1,9 @@ export function sum(values) { // implementar logica aqui - var total = 0; - for(var i = 0; i < values.length;i++) + let total = 0; + for(let i = 0; i < values.length;i++) { - total += Number(values[i]); + total += values[i]; } return total; } \ No newline at end of file diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..a8e1efe 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,16 @@ export function sumEven(value) { // implementar logica aqui - + let total = 0 + let even = [] + + for (let i = 0; i < value.length; i++) { + if (value[i] % 2 == 0) { + even.push(value[i]) + } + } + for (let i = 0; i < even.length; i++) + { + total += even[i]; + } + return total; } \ No newline at end of file -- 2.34.1 From c220c97b54c1add2d07e1dbdabbb7d3dac44233e Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Wed, 2 Nov 2022 09:05:37 -0300 Subject: [PATCH 09/11] feat(08): finished --- 08-isAnagram/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..6b4cc8f 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,12 @@ export function isAnagram(word1, word2) { // implementar logica aqui + if (word1.length !== word2.length) { + return false; + } -} \ No newline at end of file + let palavra1 = word1.toLowerCase().split('').sort().join(''); + let palavra2 = word2.toLowerCase().split('').sort().join(''); + + let result = (palavra1 === palavra2); + return result; +} -- 2.34.1 From c9e9d4a2e0a98609ca346564dd48b5de0a7c6cee Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Wed, 2 Nov 2022 10:13:47 -0300 Subject: [PATCH 10/11] feat(09): finished --- 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..d288f02 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,13 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + + let maxLetter = 0; + let mostUsed = ''; + text.split('').forEach((letter) => { + if (text.split(letter).length > maxLetter) { + maxLetter = text.split(letter).length - 1; + mostUsed = letter; + } + }) + return mostUsed; } \ No newline at end of file -- 2.34.1 From ac37e689f82ea274843ad59dc2d05bc7a85504ef Mon Sep 17 00:00:00 2001 From: Matheus Brollo Dauter Date: Wed, 2 Nov 2022 12:48:51 -0300 Subject: [PATCH 11/11] feat(10): finished --- 09-mostRepeatedChar/index.js | 2 +- 10-longestWords/index.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index d288f02..ad0fa71 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -5,7 +5,7 @@ export function mostUsedChar(text) { let mostUsed = ''; text.split('').forEach((letter) => { if (text.split(letter).length > maxLetter) { - maxLetter = text.split(letter).length - 1; + maxLetter = text.split(letter).length; mostUsed = letter; } }) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..fb9d583 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,13 @@ export function longestWords(words) { // implementar logica aqui - -} \ No newline at end of file + + return words.reduce((longest, sentence, i) => { + if (!i || longest[0].length < sentence.length) { + return [sentence]; + } + if (longest[0].length === sentence.length) { + longest.push(sentence); + } + return longest; + }, []); + } \ No newline at end of file -- 2.34.1