We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c3c426c commit 8e477f5Copy full SHA for 8e477f5
src/underbar.js
@@ -8,6 +8,7 @@ var _ = {};
8
// seem very useful, but remember it--if a function needs to provide an
9
// iterator when the user does not pass one in, this will be handy.
10
_.identity = function(val) {
11
+ return val;
12
};
13
14
/**
@@ -38,6 +39,9 @@ var _ = {};
38
39
// Like first, but for the last elements. If n is undefined, return just the
40
// last element.
41
_.last = function(array, n) {
42
+ return n === undefined ? array[array.length-1] :
43
+ n>=array.length ? array :
44
+ array.slice(array.length-n, array.length);
45
46
47
// Call iterator(value, key, collection) for each element of collection.
0 commit comments