diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..9151855 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,18 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" + let cont = 0, i, j, contador = 0, valorFinal; + let texto = text.split(""); + + for (let i = 0; i < texto.length; i++) { + cont = 0; + for (let j = 0; j < texto.length; j++) { + if (texto[i].toUpperCase() === texto[j].toUpperCase()) { + cont++ + } + } + if (cont >= contador) { + contador = cont; + valorFinal = texto[i] + } + } + return valorFinal; } \ No newline at end of file