challenge-algorithms-v2.0-E.../09-mostRepeatedChar/index.js

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