diff --git a/lodash.js b/lodash.js index cc73224bd..bfadc4c4d 100644 --- a/lodash.js +++ b/lodash.js @@ -585,6 +585,7 @@ * // => 2 */ var find = createIterator(baseIteratorOptions, { + 'init': '', 'inLoop': 'if (callback(collection[index], index, collection)) return collection[index]' }); diff --git a/test/test.js b/test/test.js index 2036fa49b..9eb1b1844 100644 --- a/test/test.js +++ b/test/test.js @@ -174,6 +174,22 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.find'); + + (function() { + var array = [1, 2, 3, 4]; + + test('should return found `value`', function() { + equal(_.find(array, function(n) { return n > 2; }), 3); + }); + + test('should return `undefined` if `value` is not found', function() { + equal(_.find(array, function(n) { return n == 5; }), undefined); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.flatten'); (function() {