forked from M3-Academy/challenge-algorithms-v2.0
26 lines
565 B
JavaScript
26 lines
565 B
JavaScript
export function mostUsedChar(text) {
|
|
// implementar logica aqui
|
|
let cont=0, maior=0
|
|
|
|
let resp = text.toLowerCase()
|
|
|
|
let i = 0, j = 0
|
|
for(i = 0; i < text.length; i++)
|
|
{
|
|
cont = 0
|
|
for(j = 0; j < text.length; j++)
|
|
{
|
|
if(resp[i] == text[j])
|
|
{
|
|
cont++
|
|
}
|
|
}
|
|
if(maior < cont)
|
|
{
|
|
maior = cont
|
|
var resposta = resp[i]
|
|
}
|
|
}
|
|
|
|
return resposta
|
|
} |