I am trying to sum up the numbers inside an array e.g. from here: https://jsfiddle.net/4r8dtxhz/12/
here is the Code:
var someObj = [{name:"hi", series: [1,2,10,4,5,6]},{name:"ho",series:[3,7,6,9,12,1,3,20,3,1]}]
for (var doc of someObj) {
this.min = doc.series.reduce((agg,val) => val < agg? val:agg, doc.series[0]);
this.max = doc.series.reduce((agg,val) => val > agg? val:agg, doc.series[0]);
}
console.log(max)
var test = Array.from(someObj.map((doc)=>doc.series)).reduce((accumulator, currentValue) => accumulator + currentValue);
console.log(typeof test)
console.log(test)
I was expecting the reduce function to sum up the numbers in the object series array... so I am wondering what goes wrong here?