We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 307239a commit 29a88dcCopy full SHA for 29a88dc
lesson_12/structs_ts/src/stack.ts
@@ -23,13 +23,10 @@ export class Stack {
23
}
24
25
peek(): number | null {
26
- if (this.top === null) {
+ if (this.top === undefined) {
27
throw new Error('Empty List');
28
29
- if (this.top !== undefined) {
30
- return this.top.val;
31
- }
32
- throw new Error('Empty List');
+ return this.top.val;
33
34
35
isEmpty(): boolean {
0 commit comments