feature/algoritmos #1

Merged
cainamilech merged 12 commits from feature/algoritmos into master 2022-10-29 19:58:08 +00:00
Showing only changes of commit 7acb5a25b3 - Show all commits

View File

@ -1,4 +1,20 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui
return "" const objeto = {};
let repeticoes = 0;
let maisRepetida = '';
for(let i of text){
objeto[i] = objeto[i] +1 || 1;
}
for(let i in objeto){
if(objeto[i] > repeticoes){
repeticoes = objeto[i];
maisRepetida = i;
}
}
return maisRepetida;
} }