feature-algorithms #1

Merged
JoseGregorioMataRodriguez merged 10 commits from feature-algorithms into master 2022-10-29 04:37:09 +00:00
Showing only changes of commit 29ab122a2f - Show all commits

View File

@ -1,4 +1,25 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
if (text.length == 0)
return console.log('Escreva alguma coisa pra consultar');
else {
let cont = 1;
let letra;
for (let i = 0; i < text.length; i++) {
let cont2 = 1;
for (let j = 0; j < text.length; j++) {
if (j !== i) {
if (text[i] === text[j])
cont2++;
if (cont2 > cont) {
cont = cont2;
letra = text[i];
}
}
}
}
return letra;
}
}