Make _.add, _.subtract, and _.sum not skip NaN values.

This commit is contained in:
John-David Dalton
2015-12-19 10:37:49 -06:00
parent 9e99a57615
commit 4b77b7a8b3
2 changed files with 17 additions and 11 deletions

View File

@@ -835,7 +835,7 @@
while (++index < length) {
var current = iteratee(array[index]);
if (current === current && current != null) {
if (current !== undefined) {
result = result === undefined ? current : (result + current);
}
}
@@ -13461,10 +13461,10 @@
*/
function add(augend, addend) {
var result;
if (augend === augend && augend != null) {
if (augend !== undefined) {
result = augend;
}
if (addend === addend && addend != null) {
if (addend !== undefined) {
result = result === undefined ? addend : (result + addend);
}
return result;
@@ -13677,10 +13677,10 @@
*/
function subtract(minuend, subtrahend) {
var result;
if (minuend === minuend && minuend != null) {
if (minuend !== undefined) {
result = minuend;
}
if (subtrahend === subtrahend && subtrahend != null) {
if (subtrahend !== undefined) {
result = result === undefined ? subtrahend : (result - subtrahend);
}
return result;