Skip to content

Commit a0e67d0

Browse files
committed
Added and completed "filter" for Underbar.
1 parent ab5fb7b commit a0e67d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/underbar.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ var _ = {};
8282

8383
// Return all elements of an array that pass a truth test.
8484
_.filter = function(collection, test) {
85+
var results = [];
86+
87+
_.each(collection, function(item, index) {
88+
if (test(item)) {
89+
results.push(item);
90+
}
91+
});
92+
93+
return results;
8594
};
8695

8796
// Return all elements of an array that don't pass a truth test.

0 commit comments

Comments
 (0)