I have this simple array with numbers:
var arr = [100,200,undefined,450,300];
I would like to use reduceto quickly sum the values in this array, for example ...
var total = arr.reduce( function( s, v ){ return s += v } );
In returnI get NaN.
Is there any way to do reduceto sum values in an array with undefined values? like a flag or something ... Thank you!
source
share