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

12 lines
248 B
JavaScript
Raw Normal View History

export function mostUsedChar(text) {
2022-11-03 00:37:28 +00:00
let count = 0,
letter = "";
text.split("").forEach(function (char) {
if (text.split(char).length > count) {
2022-11-03 00:43:51 +00:00
count = text.split(char).length;
2022-11-03 00:37:28 +00:00
letter = char;
}
});
return letter;
}