Skip to content

Commit d6af86e

Browse files
author
AmiyahJo
committed
fix: alter this.top in stack.ts
1 parent d511f07 commit d6af86e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lesson_12/structs_ts/src/stack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Stack {
1919
}
2020

2121
const value = this.top?.val;
22-
this.top = this.top!.next;
22+
this.top = this.top?.next;
2323
return value;
2424
}
2525

@@ -28,7 +28,7 @@ export class Stack {
2828
return null;
2929
}
3030

31-
return this.top!.val;
31+
return this.top?.val;
3232
}
3333

3434
isEmpty(): boolean {

0 commit comments

Comments
 (0)