Skip to content

Commit 394abcf

Browse files
author
AmiyahJo
committed
fix: final adjustments with peek() return undefined to null
1 parent 7ca9a49 commit 394abcf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lesson_12/structs_ts/src/stack.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ 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

2626
peek(): number | null {
2727
if (this.isEmpty()) {
28-
return undefined;
28+
return null;
2929
}
3030

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

3434
isEmpty(): boolean {

0 commit comments

Comments
 (0)