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) +} 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 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 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; +}