From fb7eb92a5442482af05dc1ff21fc9cde9952dba8 Mon Sep 17 00:00:00 2001 From: "Henrique@Martins" Date: Sat, 29 Oct 2022 12:59:29 -0300 Subject: [PATCH] feat(09-mostRepeatedChar)executa exercicio 9 --- 09-mostRepeatedChar/index.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..c3e8388 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,26 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + let cont=0, maior=0 + + let resp = text.toLowerCase() + + let i = 0, j = 0 + for(i = 0; i < text.length; i++) + { + cont = 0 + for(j = 0; j < text.length; j++) + { + if(resp[i] == text[j]) + { + cont++ + } + } + if(maior < cont) + { + maior = cont + var resposta = resp[i] + } + } + + return resposta } \ No newline at end of file