Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
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