Skip to content

Commit 8d02c66

Browse files
day 22 task complete
1 parent fcdf705 commit 8d02c66

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

day22/leetcode2619.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// 2619. Array Prototype Last
2+
// URL -> https://leetcode.com/problems/array-prototype-last
3+
4+
/**
5+
* @return {null|boolean|number|string|Array|Object}
6+
*/
7+
Array.prototype.last = function () {
8+
if (this.length < 1) {
9+
return -1;
10+
}
11+
return this[this.length - 1]
12+
};
13+
14+
/**
15+
* const arr = [1, 2, 3];
16+
* arr.last(); // 3
17+
*/

0 commit comments

Comments
 (0)