Skip to content

Commit a710da9

Browse files
committed
array prototype last solution
1 parent 210c9e5 commit a710da9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

easy/array-prototype-last.js

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

0 commit comments

Comments
 (0)