Merge pull request 'feat(mostRepeatedChar): implementa funcao mostUsedChar' (#9) from feature/mostRepeatedChar into development

Reviewed-on: #9
This commit is contained in:
DaviKlein 2022-10-28 22:12:14 +00:00
commit 3a1d989294

View File

@ -1,4 +1,20 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let array = text.replace('').toLowerCase().split('')
let indice;
let repeticoes=0;
let auxiliar=0;
for(let i=0;i < array.length;i++){
for(let j = 0;j < array.length;j++){
if(array[i] == array[j]){
auxiliar++
}
if(auxiliar > repeticoes){
repeticoes = auxiliar
auxiliar = 0
indice = array[i]
}
}
}
return indice
}