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

15 lines
273 B
JavaScript
Raw Permalink Normal View History

export function mostUsedChar(text) {
let h = new Set();
for(let i = 1; i <= text.length - 1; i++)
{
let c = text[i];
if (h.has(c))
return c;
else
h.add(c);
}
return '\0';
}