From 71372a1e847b9449d516f8b3a7dbf7376728a5e6 Mon Sep 17 00:00:00 2001 From: ThiagoDuutra Date: Fri, 28 Oct 2022 17:06:55 -0300 Subject: [PATCH] feat: Resolvido questao mostRepeatedChar --- 09-mostRepeatedChar/index.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..d918f39 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,20 @@ export function mostUsedChar(text) { - // implementar logica aqui - return "" -} \ No newline at end of file + // implementar logica aqui + let newText = text.toLowerCase(); + let newLetterRep; + let letraRep = 0; + for (let i = 0; i < newText.length; i++) { + let letra = newText[i]; + let cont = 0; + for (let j = 0; j < newText.length; j++) { + if (letra == newText[j]) { + cont++; + if (cont > letraRep) { + letraRep = cont; + newLetterRep = newText[i]; + } + } + } + } + return newLetterRep; +} -- 2.34.1