forked from M3-Academy/challenge-algorithms-v2.0
19 lines
602 B
JavaScript
19 lines
602 B
JavaScript
export function mostUsedChar(text) {
|
|
// implementar logica aqui
|
|
let result = '';
|
|
let mostUsedCount = 0;
|
|
for (const letter of text) {
|
|
let countLetter = 0;
|
|
for (const letterToCount of text) {
|
|
if (letterToCount === letter) {
|
|
countLetter++;
|
|
}
|
|
}
|
|
if (countLetter > mostUsedCount) {
|
|
mostUsedCount = countLetter;
|
|
result = letter;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
} |