Skip to content

Commit 5a7cd18

Browse files
authored
fix: update ts solution to lc problem: No.2619 (doocs#1316)
2619.Array Prototype Last
1 parent f743fc4 commit 5a7cd18

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

solution/2600-2699/2619.Array Prototype Last/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ declare global {
5454
}
5555

5656
Array.prototype.last = function () {
57-
return this[this.length - 1] ?? -1;
57+
return this.length ? this.at(-1) : -1;
5858
};
5959

6060
/**
6161
* const arr = [1, 2, 3];
6262
* arr.last(); // 3
6363
*/
64+
65+
export {};
6466
```
6567

6668
### **...**

solution/2600-2699/2619.Array Prototype Last/README_EN.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ declare global {
4646
}
4747

4848
Array.prototype.last = function () {
49-
return this[this.length - 1] ?? -1;
49+
return this.length ? this.at(-1) : -1;
5050
};
5151

5252
/**
5353
* const arr = [1, 2, 3];
5454
* arr.last(); // 3
5555
*/
56+
57+
export {};
5658
```
5759

5860
### **...**

solution/2600-2699/2619.Array Prototype Last/Solution.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ declare global {
55
}
66

77
Array.prototype.last = function () {
8-
return this[this.length - 1] ?? -1;
8+
return this.length ? this.at(-1) : -1;
99
};
1010

1111
/**
1212
* const arr = [1, 2, 3];
1313
* arr.last(); // 3
1414
*/
15+
16+
export {};

0 commit comments

Comments
 (0)