File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ export class Lesson12 {
25
25
}
26
26
27
27
if ( scoreEven > scoreOdd ) {
28
- return " Even" ;
28
+ return ' Even' ;
29
29
} else if ( scoreEven < scoreOdd ) {
30
- return " Odd" ;
30
+ return ' Odd' ;
31
31
} else {
32
- return " Tie" ;
32
+ return ' Tie' ;
33
33
}
34
34
}
35
35
Original file line number Diff line number Diff line change @@ -12,20 +12,20 @@ export class Stack {
12
12
this . top = newNode ;
13
13
}
14
14
15
- pop ( ) : number {
15
+ pop ( ) : number | undefined {
16
16
if ( this . isEmpty ( ) ) {
17
- throw new Error ( " Stack is empty" ) ;
17
+ throw new Error ( ' Stack is empty' ) ;
18
18
}
19
- const value = this . top ! . val ; // Non-null assertion since we've checked for emptiness
19
+ const value = this . top ? .val ; // Non-null assertion since we've checked for emptiness
20
20
this . top = this . top ?. next ; // No change needed here, TypeScript allows accessing next
21
21
return value ;
22
22
}
23
23
24
- peek ( ) : number {
24
+ peek ( ) : number | undefined {
25
25
if ( this . isEmpty ( ) ) {
26
- throw new Error ( " Stack is empty" ) ;
26
+ throw new Error ( ' Stack is empty' ) ;
27
27
}
28
- return this . top ! . val ; // Non-null assertion since we've checked for emptiness
28
+ return this . top ? .val ; // Non-null assertion since we've checked for emptiness
29
29
}
30
30
31
31
isEmpty ( ) : boolean {
You can’t perform that action at this time.
0 commit comments