Merge pull request 'feat(mostRepeatedChar): implementa funcao mostUsedChar' (#9) from feature/mostRepeatedChar into development
Reviewed-on: #9
This commit is contained in:
commit
3a1d989294
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user