-
Notifications
You must be signed in to change notification settings - Fork 6k
/
Copy pathstack.js
34 lines (30 loc) · 848 Bytes
/
stack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { NotImplementedError } = require('../extensions/index.js');
/**
* Implement the Stack with a given interface via array.
*
* @example
* const stack = new Stack();
*
* stack.push(1); // adds the element to the stack
* stack.peek(); // returns the peek, but doesn't delete it, returns 1
* stack.pop(); // returns the top element from stack and deletes it, returns 1
* stack.pop(); // undefined
*
*/
class Stack {
push(/* element */) {
throw new NotImplementedError('Not implemented');
// remove line with error and write your code here
}
pop() {
throw new NotImplementedError('Not implemented');
// remove line with error and write your code here
}
peek() {
throw new NotImplementedError('Not implemented');
// remove line with error and write your code here
}
}
module.exports = {
Stack
};