Last active
March 14, 2016 10:44
-
-
Save hoosin/234caa1f32985ea82550 to your computer and use it in GitHub Desktop.
toUpperCase
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 numToChar(str) { | |
var chartArr = str.split(""); | |
var chartLib = { | |
a: 1, | |
b: 2, | |
c: 3, | |
d: 4, | |
e: 5, | |
f: 6, | |
g: 7, | |
h: 8, | |
i: 9, | |
j: 10, | |
k: 11, | |
l: 12, | |
m: 13, | |
n: 14, | |
o: 15, | |
p: 16, | |
q: 17, | |
r: 18, | |
s: 19, | |
t: 20, | |
u: 21, | |
v: 22, | |
w: 23, | |
x: 24, | |
y: 25, | |
z: 26 | |
}; | |
var chartNumArr = chartArr.reverse().map(function(item) { | |
return chartLib[item]; | |
}) //[23,23,10] | |
var str = Math.max.apply(Math, chartNumArr) + 10; | |
var num = 0; | |
for (var i = 0, len = chartNumArr.length; i < len; i++) { | |
num += (chartNumArr[i] + 9) * Math.pow(str, i); | |
} | |
console.log("(" + num + ")" + ".toString(" + str + ")"); | |
console.log((num).toString(str)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
goood!i feel like this author is a fucking genius XD