Skip to content

Commit f637f8b

Browse files
chore: fixed syntax
1 parent 151d59c commit f637f8b

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

lesson_12/structs_ts/src/lesson12.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ export class Lesson12 {
99
let e_pts = 0;
1010
let o_pts = 0;
1111

12-
if (head === null){
13-
return "";
12+
if (head === null) {
13+
return '';
1414
}
1515

1616
let curr: ListNode | undefined = head;
1717

1818
while (curr != null) {
19-
let next: ListNode | undefined = curr.next;
20-
if (next === undefined){
21-
return "";
19+
const next: ListNode | undefined = curr.next;
20+
if (next === undefined) {
21+
return '';
2222
}
23-
if (curr.val > next!.val){
23+
if (curr.val > next?.val) {
2424
e_pts++;
25-
} else if (curr.val < next!.val){
25+
} else if (curr.val < next?.val) {
2626
o_pts++;
2727
}
2828
curr = next.next;
2929
}
3030

3131
if (e_pts === o_pts) {
32-
return "Tie";
32+
return 'Tie';
3333
}
3434

35-
return e_pts > o_pts ? "Even" : "Odd";
35+
return e_pts > o_pts ? 'Even' : 'Odd';
3636
}
3737
}

lesson_12/structs_ts/src/stack.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ export class Stack {
88
}
99

1010
push(value: number): void {
11-
let node: ListNode | undefined = new ListNode(value);
11+
const node: ListNode | undefined = new ListNode(value);
1212

1313
node.next = this.top;
1414
this.top = node;
15-
1615
}
1716

1817
pop(): number | undefined {
19-
if(this.isEmpty()){
18+
if (this.isEmpty()) {
2019
throw new Error('Stack is empty');
2120
}
2221

23-
if (this.top){
24-
let value_to_pop: number = this.top.val
22+
if (this.top) {
23+
const value_to_pop: number = this.top.val;
2524
this.top = this.top.next;
2625
return value_to_pop;
2726
}
@@ -30,16 +29,15 @@ export class Stack {
3029
}
3130

3231
peek(): number | null {
33-
if (this.isEmpty()){
32+
if (this.isEmpty()) {
3433
throw new Error('Stack is empty');
3534
}
3635

37-
if (this.top){
36+
if (this.top) {
3837
return this.top.val;
3938
}
4039

4140
return null;
42-
4341
}
4442

4543
isEmpty(): boolean {

0 commit comments

Comments
 (0)