From 29679d802cf63f931d9d9f2268ef1db84232a272 Mon Sep 17 00:00:00 2001 From: Carlos Scantbelruy Date: Fri, 28 Oct 2022 08:22:17 -0400 Subject: [PATCH 1/4] retonando o anagrama --- 08-isAnagram/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..b372722 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,8 @@ export function isAnagram(word1, word2) { - // implementar logica aqui - + if (word1.length !== word2.length) { + return false; +} +if (word1.length === word2.length) { + return true; +} } \ No newline at end of file From 64ba560b3c3dc6b8666c4cd8f6d5011976c58ff0 Mon Sep 17 00:00:00 2001 From: Carlos Scantbelruy Date: Fri, 28 Oct 2022 08:27:02 -0400 Subject: [PATCH 2/4] Retornando a letra mais repetida de uma string --- 09-mostRepeatedChar/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..b166777 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,15 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" + let h = new Set(); + + for(let i = 1; i <= text.length - 1; i++) + { + let c = text[i]; + + if (h.has(c)) + return c; + + else + h.add(c); + } + return '\0'; } \ No newline at end of file From 5aebe7e4f92ee998ce4a36fbe3092cdd0cb1741b Mon Sep 17 00:00:00 2001 From: Carlos Scantbelruy Date: Fri, 28 Oct 2022 08:59:53 -0400 Subject: [PATCH 3/4] retornando a maior palavra de um array --- 10-longestWords/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..9d3e1b3 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,7 @@ export function longestWords(words) { - // implementar logica aqui - -} \ No newline at end of file + var longest = ""; + for (var word of words) { + if (words.length > longest.length) longest = words; + } + return longest; +} From 5181e18b04b81902720a2af9c258c69a5279b02e Mon Sep 17 00:00:00 2001 From: Carlos Scantbelruy Date: Fri, 28 Oct 2022 09:11:28 -0400 Subject: [PATCH 4/4] Retornando fibonacci --- 04-fibonacci/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..ab5ba8c 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,6 @@ export function fibonacci(value) { - // implementar logica aqui - -} \ No newline at end of file + if(value < 2) { + return value + } + return fibonacci(value - 1) + fibonacci(value - 2) +}