I want make a stack that return lowest element in the stack storage by call min property of MinimumStack


//Please help
function Stack(capacity){
    this._capacity = capacity;
    this._storage = {};
    this._count = 0;

} 
Stack.prototype.push= function(val){
    if (this._count < this._capacity){
        this._storage[this._count++] = val;
        return this._count;
    }
    return "Maximum Storage Reached";
}
 Stack.prototype.pop = function(){
     if (this._count > 0){
        var value = this._storage[--this._count];
        delete this._storage[this._count];
        return value;
     }
     return "empty"
 }
 Stack.prototype.count = function(){
     return this._count;
 }
 Stack.prototype.peek = function(){
     if (this._count > 0){
     return this._storage[this._count-1];
     }
     return "empty";
 }
var MinimumStack = function(capacity){
    this.capacity = capacity,
    this.storage = {},
    this.count = 0;
    this.min = new Stack();
    }
 MinimumStack.prototype.push = function(value){
     if(this.capacity > this.count){
        if(this.min.peek() < value){
             this.min.push(this.min.peek());
             console.log(this.min.peek());
         }
         else{
             this.min.push(value);
         }
         this.storage[this.count++] = value;
         return this.count;
     }
     return "Reached Maximum Storage";
 }
 MinimumStack.prototype.minimum = function(){
    console.log(this.min.peek());
 }
 var myStack = new MinimumStack(5);

Can you formulate an actual question?

Your title could mean a million things.

this.min = new Stack();

function Stack(capacity){

You’re not passing anything.

i want make a stack that return lowest element in the stack storage by call min property of MinimumStack, but min is not returning undefined

What commands are you running?

thank you.
this thing worked ,this was very silly mistake i made!!
:slight_smile: