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

13 lines
322 B
JavaScript

export function mostUsedChar(text) {
// implementar logica aqui
let maxLetter = 0;
let mostUsed = '';
text.split('').forEach((letter) => {
if (text.split(letter).length > maxLetter) {
maxLetter = text.split(letter).length;
mostUsed = letter;
}
})
return mostUsed;
}