You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
374 B
20 lines
374 B
export default function(values, valueof) {
|
|
var n = values.length,
|
|
i = -1,
|
|
value,
|
|
sum = 0;
|
|
|
|
if (valueof == null) {
|
|
while (++i < n) {
|
|
if (value = +values[i]) sum += value; // Note: zero and null are equivalent.
|
|
}
|
|
}
|
|
|
|
else {
|
|
while (++i < n) {
|
|
if (value = +valueof(values[i], i, values)) sum += value;
|
|
}
|
|
}
|
|
|
|
return sum;
|
|
}
|