forked from M3-Academy/challenge-algorithms-v2.0
feat: cria algoritmo que retorne a a letra mias repetida de uma string.
This commit is contained in:
parent
5a8fa6be43
commit
835230d507
@ -1,4 +1,17 @@
|
||||
export function mostUsedChar(text) {
|
||||
// implementar logica aqui
|
||||
return ""
|
||||
let char = '';
|
||||
let repeatLetter = 0;
|
||||
for (const character of text) {
|
||||
let countLetter = 0;
|
||||
for (const verifyCharacter of text) {
|
||||
if (character === verifyCharacter)
|
||||
countLetter++
|
||||
}
|
||||
if (countLetter > repeatLetter) {
|
||||
repeatLetter = countLetter;
|
||||
char = character
|
||||
}
|
||||
}
|
||||
return char;
|
||||
}
|
Loading…
Reference in New Issue
Block a user