十进制转换为2~36的任意进制
/**
* 十进制转换为2~36的任意进制
*/
const baseConverter = (number = 12138, base = 2) => { if(base < 2 || base > 36) return new Error('进制参数错误') const stack = [] const digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' while (number > 0) { const rem = number % base stack.push(rem) number = Math.floor(number / base) } let res = '' while (stack.length) { res += digits[stack.pop()] } return res }
以自己现在的努力程度,还没有资格和别人拼天赋