var divBy2 = function(number,n){ var stack = new Stack(); //实例化队列 var yushu = 0; var string2 = ''; var digits = '0123456789ABCDEF'; while(number > 0){ yushu = number % n; stack.push(yushu); number = Math.floor(number / n); } while(!stack.isEmpty()){ console.log(typeof digits) string2+=digits[stack.pop()]; } return string2; } console.log(divBy2(10,2))