Merge branch 'feature/09-mostRepeatedChar' into developer

This commit is contained in:
Matheus Mariosa 2022-11-02 13:38:00 -03:00
commit 1c2a3ae877

View File

@ -1,4 +1,22 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui // implementar logica aqui
return "" const boxChar = {};
let max = 0;
let result = '';
for(let char of text){
if(boxChar[char]){
boxChar[char]++;
}else{
boxChar[char] = 1;
}
}
for(let char in boxChar){
if(boxChar[char] > max){
max = boxChar[char];
result = char;
}
}
return result;
} }