I have the following code:
if (this.places.length) {
console.log(this.places);
var myData = this.places.map(({ points }) => points);
var myTotal = 0; // Variable to hold your total
for(var i = 0, len = myData.length; i < len; i++) {
myTotal += myData[i][1]; // Iterate over your first array and then grab the second element add the values up
}
console.log(myTotal);
}
I have an object see
, from that object i need to extract all arrays, and from that arrays just a particular value, for example points.
The main goal is to sum and save all points into a new variable. The code from abobe it's not working.