Description: The project requires that the numbers corresponding to the price field in the data be taken out and added. The sum of its data is computed and passed to the back end. The main methods used are math.pow, math.max, math.round. See the following code for details:

function(arr){ const fieldArr = []; for (var i = 0; i < arr.length; i++) { var m, field; try { field = arr[i].toString().split(".")[1].length; } catch (e) { field = 0; } fieldArr.push(field); } m = Math.pow(10, Math.max(... fieldArr)); let add = 0; arr.forEach(function (item) { add = add + item * m; }); let sum = Math.round(add) / m; return sum; }Copy the code

Arr is the array to be evaluated