function Stack() {
let items = [];
this.push = function(element) {
items.push(element);
}
this.pop = function() {
return items.pop();
}
this.peek = function() {
return items[items.length - 1];
}
this.isEmpty = function() {
return items.length === 0;
}
this.size = function() {
return items.length;
}
this.printStack = function() {
console.log(items.toString());
}
}
function tenSwitchAny(x, base) {
let remStack = new Stack(),
resultString = '',
referString = '0123456789ABCDEF';
while(x > 0) {
remStack.push(x % base);
x = Math.floor(x / base);
}
while(!remStack.isEmpty()) {
resultString += referString[remStack.pop()];
}
return resultString;
}
console