feat: Resolvido questao mostRepeatedChar

This commit is contained in:
ThiagoDuutra 2022-10-28 17:06:55 -03:00
parent 5c45023156
commit 71372a1e84

View File

@ -1,4 +1,20 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
}
// 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;
}