Merge branch 'feature/mostrepeatedchar' into development

This commit is contained in:
Marcello Rodrigues Martins 2022-10-30 17:30:54 -03:00
commit fabfc5a6f1

View File

@ -1,4 +1,16 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
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;
}