Skip to content

Commit f52ae8b

Browse files
committed
Began "every" for Underbar. "Every" still fails some tests and needs to be adjusted and finished.
1 parent c6869ca commit f52ae8b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/underbar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ var _ = {};
200200
// Determine whether all of the elements match a truth test.
201201
_.every = function(collection, iterator) {
202202
// TIP: Try re-using reduce() here.
203+
return _.reduce(collection, function(soFar, item) {
204+
if (soFar) {
205+
return iterator(item)===true;
206+
} else {
207+
return false;
208+
}
209+
}, true);
203210
};
204211

205212
// Determine whether any of the elements pass a truth test. If no iterator is

0 commit comments

Comments
 (0)