Skip to content

Commit 26f0810

Browse files
author
jjcapparell
committed
fix: errors part 1
1 parent 2eab061 commit 26f0810

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lesson_12/structs_ts/src/lesson12.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export class Lesson12 {
2525
}
2626

2727
if (scoreEven > scoreOdd) {
28-
return "Even";
28+
return 'Even';
2929
} else if (scoreEven < scoreOdd) {
30-
return "Odd";
30+
return 'Odd';
3131
} else {
32-
return "Tie";
32+
return 'Tie';
3333
}
3434
}
3535

lesson_12/structs_ts/src/stack.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ export class Stack {
1212
this.top = newNode;
1313
}
1414

15-
pop(): number {
15+
pop(): number | undefined {
1616
if (this.isEmpty()) {
17-
throw new Error("Stack is empty");
17+
throw new Error('Stack is empty');
1818
}
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
2020
this.top = this.top?.next; // No change needed here, TypeScript allows accessing next
2121
return value;
2222
}
2323

24-
peek(): number {
24+
peek(): number | undefined {
2525
if (this.isEmpty()) {
26-
throw new Error("Stack is empty");
26+
throw new Error('Stack is empty');
2727
}
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
2929
}
3030

3131
isEmpty(): boolean {

0 commit comments

Comments
 (0)