Merge branch 'feature/mostRepeatedChar' into development

This commit is contained in:
Gabriel Ferreira Lehmann 2022-10-30 01:22:50 -03:00
commit c7c04e054b

View File

@ -1,4 +1,18 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let count = 0;
let char = " ";
let save = {};
text.split("").forEach((letter) => {
if(save[letter]){
save[letter] += 1;
} else {
save[letter] = 1;
}
if(save[letter] > count){
count = save[letter];
char = letter;
}
})
return char;
}