Merge pull request 'feat: implementa função do caractere mais repetido' (#9) from feature/mostReapeatedChar into development

Reviewed-on: #9
This commit is contained in:
RodrigoJorge 2022-10-28 19:45:31 +00:00
commit a36b188134

View File

@ -1,4 +1,16 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
}
const Objeto = {};
let Contador = 0;
let mostUsedChar = "";
for (let char of text) {
Objeto[char] = Objeto[char] + 1 || 1;
}
for (let key in Objeto) {
if (Objeto[key] > Contador) {
Contador = Objeto[key];
mostUsedChar = key;
}
}
return mostUsedChar;
}