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