diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..1a4d0f2 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,17 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + let char = ''; + let repeatLetter = 0; + for (const character of text) { + let countLetter = 0; + for (const verifyCharacter of text) { + if (character === verifyCharacter) + countLetter++ + } + if (countLetter > repeatLetter) { + repeatLetter = countLetter; + char = character + } + } + return char; } \ No newline at end of file