Merge pull request 'feat(home):resolucao da questao 9' (#9) from feature/exercicio9 into development

Reviewed-on: #9
This commit is contained in:
Edna Barboza de Lima 2022-10-28 12:22:10 +00:00
commit b717944520

View File

@ -1,4 +1,27 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let order = text.toLowerCase().split('').sort();
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;
}