forked from M3-Academy/challenge-algorithms-v2.0
14 lines
362 B
JavaScript
14 lines
362 B
JavaScript
export function mostUsedChar(text) {
|
|
// implementar logica aqui
|
|
let counts = {};
|
|
Array.from(text).forEach((count) => {
|
|
counts[count] = (counts[count] || 0) + 1;
|
|
});
|
|
|
|
const maxVal = Math.max(...Object.values(counts));
|
|
const num = Object.keys(counts).find((key) => {
|
|
return counts[key] === maxVal;
|
|
});
|
|
|
|
return num;
|
|
} |