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