From 424300248be8836691130aec8d12612f715381e5 Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 12:56:32 -0300 Subject: [PATCH 1/9] =?UTF-8?q?feat:=20Adicionar=20c=C3=B3digo=20dos=20des?= =?UTF-8?q?afios=201=20e=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 01-greeting/index.js | 3 ++- 02-triangleArea/index.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/01-greeting/index.js b/01-greeting/index.js index 8f551af..85600ec 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,5 @@ 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..71ecb21 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 From eff82acf6d9e3a9d258c3f924c86be1ef77322c3 Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 13:28:42 -0300 Subject: [PATCH 2/9] =?UTF-8?q?feat:=20Adiciona=20o=20c=C3=B3digo=20do=20d?= =?UTF-8?q?esafio=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-maxValue/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..a588023 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,9 @@ export function maxValue(values) { // implementar logica aqui + if (values.length == 0) + + return 0; + + return Math.max(...values,); } \ No newline at end of file From a847d935591492524034eae0d1311afe89eacc07 Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 13:50:56 -0300 Subject: [PATCH 3/9] =?UTF-8?q?feat:=20Adiciona=20o=20c=C3=B3digo=20do=20d?= =?UTF-8?q?esafio=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 04-fibonacci/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..be20017 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,7 @@ export function fibonacci(value) { // implementar logica aqui - + let phi = (1 + Math.sqrt(5))/2; + let asymp = Math.pow(phi, value) / Math.sqrt(5); + + return Math.round(asymp); } \ No newline at end of file From a3ba7348e9cf4e66cb0a75da694c0e59f58f048f Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 13:55:02 -0300 Subject: [PATCH 4/9] =?UTF-8?q?feat:=20Adiciona=20o=20c=C3=B3digo=20do=20d?= =?UTF-8?q?esafio=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 05-isPrime/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..e61acdc 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,9 @@ export function isPrime(value) { // implementar logica aqui + if (value === 0 || value === 1) return false; + for (let i = 2; i <= Math.sqrt(value); i++) { + if (value % i === 0) return false; + } + return true; } \ No newline at end of file From 11dc947debd8d8ac353af29035a10c490ec7e4d3 Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 13:56:52 -0300 Subject: [PATCH 5/9] =?UTF-8?q?feat:=20Adiciona=20o=20c=C3=B3digo=20do=20d?= =?UTF-8?q?esafio=206?= 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..4d6b912 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((total, values) => total + values, 0); } \ No newline at end of file From 053f15c827e3cff70e1d7ddaf6e6b424b0109ea0 Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 13:58:28 -0300 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20Adiciona=20o=20c=C3=B3digo=20do=20d?= =?UTF-8?q?esafio=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 07-sumEven/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..3b23156 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,4 @@ export function sumEven(value) { // implementar logica aqui - + return value.reduce((acc,curr)=>acc + (curr % 2 == 0 ? curr : 0), 0); } \ No newline at end of file From fa1f7a6cd0529797c929db7a5f44f6928b3b531c Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 14:00:03 -0300 Subject: [PATCH 7/9] =?UTF-8?q?feat:=20Adiciona=20o=20c=C3=B3digo=20do=20d?= =?UTF-8?q?esafio=208?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 08-isAnagram/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..1c82f70 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,6 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + var y = word1.toLowerCase().split("").sort().join(""), + z = word2.toLowerCase().split("").sort().join(""); + return (z === y) ? true : false; } \ No newline at end of file From 1d67f416d1274cd36078b8fa85013524ec6c3487 Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 14:01:27 -0300 Subject: [PATCH 8/9] =?UTF-8?q?feat:=20Adiciona=20o=20c=C3=B3digo=20do=20d?= =?UTF-8?q?esafio=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 09-mostRepeatedChar/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..f10b302 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,8 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + const charHolder = text.toLowerCase().split('').reduce((ac,a) => (ac[a] = ac[a] + 1 || 1, ac), {}); + + let max = Math.max(...Object.values(charHolder)); + + return Object.entries(charHolder).reduce((ac,[k,v]) =>v === max ? ac + k : ac, ''); } \ No newline at end of file From 26123ac5792ea52f969a00bffdac4c6383f2be4d Mon Sep 17 00:00:00 2001 From: Gabriel Gomes Date: Mon, 31 Oct 2022 16:52:38 -0300 Subject: [PATCH 9/9] =?UTF-8?q?feat:=20Adiciona=20o=20c=C3=B3digo=20do=20d?= =?UTF-8?q?esafio=2010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10-longestWords/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..ab58490 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,13 @@ export function longestWords(words) { // implementar logica aqui + return words.reduce((r, s, i) => { + if (!i || r[0].length < s.length) { + return [s]; + } + if (r[0].length === s.length) { + r.push(s); + } + return r; + }, []); } \ No newline at end of file