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

8 lines
317 B
JavaScript
Raw Normal View History

export function mostUsedChar(text) {
// implementar logica aqui
2022-10-31 17:01:27 +00:00
const charHolder = text.toLowerCase().split('').reduce((ac,a) => (ac[a] = ac[a] + 1 || 1, ac), {});
let max = Math.max(...Object.values(charHolder));
return Object.entries(charHolder).reduce((ac,[k,v]) =>v === max ? ac + k : ac, '');
}