Skip to content

Instantly share code, notes, and snippets.

@st98
Last active August 29, 2015 14:01
Show Gist options
  • Save st98/5ddfcfdcc6f31a91de1c to your computer and use it in GitHub Desktop.
Save st98/5ddfcfdcc6f31a91de1c to your computer and use it in GitHub Desktop.
f([1, 2, 3, 4, 2, 3]); == 'ABCDBC'
function f(ary) {
var i, n, s, r, m;
s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
r = '';
m = {};
for (i = n = 0; i < ary.length; i++) {
if (m[ary[i]] == null) {
m[ary[i]] = s[n++];
}
r += m[ary[i]];
}
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment