Merge pull request 'feat: cria algoritmo que retorne a a letra mias repetida de uma string.' (#9) from feature/mostUsedChar into development/desafio-02

Reviewed-on: EmmanuelVitor/challenge-algorithms-v2.0-EmmanuelVitor#9
This commit is contained in:
Emmanuel Vitor Pereira de Jesus 2022-10-31 16:59:56 +00:00
commit 605c916b49

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;
}