2022-10-27 15:07:13 +00:00
|
|
|
export function mostUsedChar(text) {
|
|
|
|
// implementar logica aqui
|
2022-10-28 18:11:42 +00:00
|
|
|
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()
|
2022-10-27 15:07:13 +00:00
|
|
|
}
|