forked from M3-Academy/challenge-algorithms-v2.0
17 lines
456 B
JavaScript
17 lines
456 B
JavaScript
export function mostUsedChar(text) {
|
|
// implementar logica aqui
|
|
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;
|
|
} |