feature/algoritmos #1

Merged
LeonardoPereiraRocha merged 10 commits from feature/algoritmos into master 2022-11-02 20:24:57 +00:00
Showing only changes of commit d2ea761b4f - Show all commits

View File

@ -1,4 +1,19 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui let arrChar;
return "" arrChar = text.split('');
let countCharMax = 1;
let countChar = 0;
let char;
for (let i=0; i<arrChar.length; i++)
{
for (let j=i; j<arrChar.length; j++) {
if (arrChar[i] == arrChar[j])
countChar++;
if (countCharMax<countChar) {
countCharMax=countChar;
char = arrChar[i];
}
}
countChar = 0;
} return char;
} }