Merge pull request 'feat(mosrUsedChar): funcao feita' (#9) from feature/mostRepeatedChar into development

Reviewed-on: #9
This commit is contained in:
Nicolly Vieira Santos Costa 2022-10-28 18:12:28 +00:00
commit 74a08c52c7

View File

@ -1,4 +1,19 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let textLower = text.toLowerCase().split('');
let caractereMaisRepetido;
let numeroDeCaractereRepetido = 0;
textLower.forEach(element => {
let caracteresRepetidos = textLower.filter((x) => x === element);
if (caracteresRepetidos.length > numeroDeCaractereRepetido) {
caractereMaisRepetido = caracteresRepetidos.filter((caractere, indice) => {
return caracteresRepetidos.indexOf(caractere) === indice
})
numeroDeCaractereRepetido = caracteresRepetidos.length
}
});
return caractereMaisRepetido.toString()
}