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

17 lines
346 B
JavaScript

export function mostUsedChar(text) {
// implementar logica aqui
let max = 0;
let maxCaracter = "";
text.split('').forEach((caracter) => {
if (text.split(caracter).length > max) {
max = text.split(caracter).length;
maxCaracter = caracter;
}
});
return maxCaracter;
}