Skip to content

Instantly share code, notes, and snippets.

@friendlyanon
Last active September 9, 2018 22:43
Show Gist options
  • Save friendlyanon/9e3f46f97bb9b78bd021b6bd2571d6de to your computer and use it in GitHub Desktop.
Save friendlyanon/9e3f46f97bb9b78bd021b6bd2571d6de to your computer and use it in GitHub Desktop.
function isIsogram(s) {
var map, str, c, i, l, e, h;
if (typeof s !== "string") return false;
if ((l = s.length) < 2) return true;
c = (str = s.toLowerCase()).codePointAt();
if ((h = c > 0xFFFF) && l < 4) return true;
(map = {})[c] = true, e = l - 2, i = +h;
do {
if (map[c = str.codePointAt(++i)]) return false;
if (c > 0xFFFF) if (i === e) return true; else ++i;
map[c] = true;
} while (i < l);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment