feat: added solution (#34293)

This commit is contained in:
Aditya
2018-11-12 09:32:11 +05:30
committed by Christopher McCormack
parent 8d6f59dcce
commit 0c4ab033aa

View File

@ -74,6 +74,28 @@ function Stack() {
<section id='solution'>
```js
// solution required
class Stack {
constructor() {
this.collection = [];
}
print(){
console.log(this.collection);
}
push(val){
this.collection.push(val);
}
pop(){
return this.collection.pop();
}
peek(){
return this.collection[this.collection.length-1];
}
isEmpty(){
return this.collection.length === 0;
}
clear(){
return this.collection.length = 0;
}
}
```
</section>