function fn(par) {
var arr = par.split(’’);
var num = 0;
for (var i = 0; i < arr; i++) {
switch (arr[i]) {
case’a’:
arr[a] = 10;
break;
case’b’:
arr[b] = 11;
break;
case’c’:
arr[c] = 12;
break;
case’d’:
arr[d] = 13;
break;
case’e’:
arr[e] = 14;
break;
case’f’:
arr[f] = 15;
break;
}
}
// Math
/!*for (var j = 0; j < arr.length; j++) {
num += arr[j] * Math.pow(16, arr.length - 1 - j);
}*!/
//递归
for (var j = 0; j < arr.length; j++) {
num += arr[j] * ff (arr.length - 1 - j);
}
function ff (n) {
if (n<0){
return 1/16;
}
return ff(n-1)*16;
}
return console.log(num);
}
console.log(0xabdaf);*/