Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -4,5 +4,5 @@ function Stack() {
|
|||
this.push = function(element) {this.data.push(element)}
|
||||
this.pop = function() {return this.data.pop()}
|
||||
this.empty = function() {return this.data.length == 0}
|
||||
this.peek = function() {return this.data[0]}
|
||||
this.peek = function() {return this.data[this.data.length - 1]}
|
||||
}
|
||||
|
|
|
|||
24
Task/Stack/JavaScript/stack-3.js
Normal file
24
Task/Stack/JavaScript/stack-3.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
function makeStack() {
|
||||
var stack = [];
|
||||
|
||||
var popStack = function () {
|
||||
return stack.pop();
|
||||
};
|
||||
var pushStack = function () {
|
||||
return stack.push.apply(stack, arguments);
|
||||
};
|
||||
var isEmpty = function () {
|
||||
return stack.length === 0;
|
||||
};
|
||||
var peekStack = function () {
|
||||
return stack[stack.length-1];
|
||||
};
|
||||
|
||||
return {
|
||||
pop: popStack,
|
||||
push: pushStack,
|
||||
isEmpty: isEmpty,
|
||||
peek: peekStack,
|
||||
top: peekStack
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue