fix(09-mostRepeatedChar)otimiza codigo do exercicio 9

This commit is contained in:
Henrique Martins Silva 2022-10-29 14:52:43 -03:00
parent fb7eb92a54
commit 87c9a5f108

View File

@ -5,22 +5,17 @@ export function mostUsedChar(text) {
let resp = text.toLowerCase()
let i = 0, j = 0
for(i = 0; i < text.length; i++)
{
for(i = 0; i < text.length; i++){
cont = 0
for(j = 0; j < text.length; j++)
{
if(resp[i] == text[j])
{
for(j = 0; j < text.length; j++){
if(resp[i] == text[j]){
cont++
}
}
if(maior < cont)
{
if(maior < cont){
maior = cont
var resposta = resp[i]
}
}
return resposta
return resposta
}