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

12 lines
248 B
JavaScript

export function mostUsedChar(text) {
let count = 0,
letter = "";
text.split("").forEach(function (char) {
if (text.split(char).length > count) {
count = text.split(char).length;
letter = char;
}
});
return letter;
}