Last active
August 29, 2015 14:01
-
-
Save st98/5ddfcfdcc6f31a91de1c to your computer and use it in GitHub Desktop.
f([1, 2, 3, 4, 2, 3]); == 'ABCDBC'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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