forked from M3-Academy/challenge-algorithms-v2.0
Merge pull request 'feat: cria algoritmo que retorne a a letra mias repetida de uma string.' (#9) from feature/mostUsedChar into development/desafio-02
Reviewed-on: EmmanuelVitor/challenge-algorithms-v2.0-EmmanuelVitor#9
This commit is contained in:
commit
605c916b49
@ -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