forked from M3-Academy/challenge-algorithms-v2.0
16 lines
321 B
JavaScript
16 lines
321 B
JavaScript
export function mostUsedChar(text) {
|
|
var getMax = function (str) {
|
|
var max = 0,
|
|
maxChar = "";
|
|
str.split("").forEach(function (char) {
|
|
if (str.split(char).length > max) {
|
|
max = str.split(char).length;
|
|
maxChar = char;
|
|
}
|
|
});
|
|
return maxChar;
|
|
};
|
|
|
|
return getMax(text);
|
|
}
|