feat(mostRepeatedChar): adiciona resolucao questao09-mostrepeatedchar

This commit is contained in:
carloswinter 2022-10-28 16:16:15 -03:00
parent a5d512ee42
commit e4e94adf5e

View File

@ -1,4 +1,12 @@
export function mostUsedChar(text) { export function mostUsedChar(text) {
// implementar logica aqui // implementar logica aqui
return "" let max = 0;
let maxRepeated = '';
text.split('').forEach(function(char){
if(text.split(char).length > max) {
max = text.split(char).length;
maxRepeated = char;
}
});
return maxRepeated;
} }