feat: cria algoritmo que retorne a a letra mias repetida de uma string.

This commit is contained in:
Emmanuel Vitor Pereira de Jesus 2022-10-31 13:59:07 -03:00
parent 5a8fa6be43
commit 835230d507

View File

@ -1,4 +1,17 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let char = '';
let repeatLetter = 0;
for (const character of text) {
let countLetter = 0;
for (const verifyCharacter of text) {
if (character === verifyCharacter)
countLetter++
}
if (countLetter > repeatLetter) {
repeatLetter = countLetter;
char = character
}
}
return char;
}