feat(home):resolucao da questao 9 #9

Merged
ednabarboza merged 1 commits from feature/exercicio9 into development 2022-10-28 12:22:10 +00:00

View File

@ -1,4 +1,27 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui let order = text.toLowerCase().split('').sort();
return ""
let finalResult = "";
let letterMostAppears = 0;
//console.log(order) ---> verificar se transformou em array e ordenou
for(let i=0; i<order.length; i++){
let count = 0;
for(let j=1; j<order.length; j++){
//console.log(`Resultado: ${order[i]}, ${order[j]} `)
if(order[i] === order[j]){
count++;
}
}
if (count > letterMostAppears){
letterMostAppears = count;
finalResult = order[i];
}
}
return finalResult;
} }