let Stack=(function(){
const items= new WeakMap();
class Stack {
constructor(){
items.set(this,[]);
}
push(el){
let s=items.get(this);
s.push(el)
}
pop(){
let s=items.get(this)
return s.pop();
}
peek(){
let s=items.get(this)
return s[s.length-1]
}
isEmpty(){
let s=items.get(this)
return s.length==0;
}
size(){
let s=items.get(this)
return s.length;
}
clear(){
let s=items.get(this)
s=[];
}
print(){
let s=items.get(this)
console.log(s.toString());
}
}
return Stack;
})();
function divdeBy2(decNumber,base){
var remStack=new Stack(),
rem,
binaryString='',
digits='0123456789ABCDEF';
while(decNumber>0){
rem=Math.floor(decNumber%base);
remStack.push(rem);
decNumber=Math.floor(decNumber/base);
}
while(!remStack.isEmpty()){
// binaryString+=remStack.pop().toString();
binaryString+=digits[remStack.pop()];
// console.log(binaryString);
}
console.log(binaryString);
return binaryString;
}
divdeBy2(100,16)
console