//Stacks
//google
//udemy.com
//youtube
//Arrays
//Lnked Lists
//Queues
// head tail
// Matt -- Joy -- Samir -- Pavel
//Arrays
//Linked Lists
class Stack{
constructor(){
this.array = [];
}
peek(){
if(this.array.length > 0)
{
return this.array[this.array.length - 1];
}
}
push(value){
this.array.push(value) ;
return this;
}
pop(){
this.array.pop();
return this;
}
}
const MyStack = new Stack();
MyStack.push('google');
MyStack.push('udemy');
MyStack.push('discord');
console.log(MyStack.peek());
console.log(MyStack);
MyStack.pop();
MyStack.pop();
MyStack.pop();
console.log(MyStack);