Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b4c9943

Browse files
Add solution to 2619.
1 parent 80e7bd9 commit b4c9943

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎solutions/2619.array-prototype-last.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Array.prototype.last = function () {
2+
if (!this.length) {
3+
return -1;
4+
}
5+
6+
return this[this.length - 1];
7+
};
8+
9+
/**
10+
* const arr = [1, 2, 3];
11+
* arr.last(); // 3
12+
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /