There is such a multi-dimensional array that gets the value of index 1 in each subarray and calculates the sum of all the values.

I use loop traversal to figure it out, but I feel that there is too much code. I wonder if there is a better way to calculate es6

var array = [
    ["18.8000", "10.0000"]
    ["20.0000", "10.0000"]
    ["20.1000", "10.0000"]
    ["20.2000", "1370"]
    ["20.6000", "2120"]
    ["20.9000", "1480"]
]
let total = 0;
  for (let index = 0; index < array .length; indexPP) {
    const element = +array[index][1];
    total += element;
  }
  console.log(total);
Mar.12,2021

array.reduce (function (sum,item) {return sum + = + item [1]}, 0)

Menu