From dd70fcb9bc5282cdaefc858205c6a67f5f707fc4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 30 Oct 2014 23:44:19 -0700 Subject: [PATCH] Cleanup `_.dropRightWhile` and `_.takeRightWhile`. --- lodash.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lodash.js b/lodash.js index 3b006d54c..db62f1d7b 100644 --- a/lodash.js +++ b/lodash.js @@ -3507,12 +3507,11 @@ * // => ['barney', 'fred'] */ function dropRightWhile(array, predicate, thisArg) { - var length = array ? array.length : 0, - index = length; + var length = array ? array.length : 0; predicate = getCallback(predicate, thisArg, 3); - while (index-- && predicate(array[index], index, array)) {} - return slice(array, 0, index + 1); + while (length-- && predicate(array[length], length, array)) {} + return slice(array, 0, length + 1); } /** @@ -4293,12 +4292,11 @@ * // => ['pebbles'] */ function takeRightWhile(array, predicate, thisArg) { - var length = array ? array.length : 0, - index = length; + var length = array ? array.length : 0; predicate = getCallback(predicate, thisArg, 3); - while (index-- && predicate(array[index], index, array)) {} - return slice(array, index + 1); + while (length-- && predicate(array[length], length, array)) {} + return slice(array, length + 1); } /**