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

12 lines
246 B
JavaScript

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