challenge-algorithms-v2.0-c.../09-mostRepeatedChar/index.js

12 lines
316 B
JavaScript
Raw Normal View History

export function mostUsedChar(text) {
// implementar logica aqui
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;
}