2022-10-27 15:07:13 +00:00
|
|
|
export function mostUsedChar(text) {
|
|
|
|
// implementar logica aqui
|
2022-10-30 20:29:47 +00:00
|
|
|
let caractercount = 0; let caractersave = {}; let caracter = " ";
|
|
|
|
text.split("").forEach((repetido) => {
|
|
|
|
if(caractersave[repetido]){
|
|
|
|
caractersave[repetido] += 1;
|
|
|
|
} else{
|
|
|
|
caractersave[repetido] = 1;
|
|
|
|
}
|
|
|
|
if(caractersave[repetido] > caractercount){
|
|
|
|
caractercount = caractersave[repetido];
|
|
|
|
caracter = repetido;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return caracter;
|
2022-10-27 15:07:13 +00:00
|
|
|
}
|