我的函数在添加总和之后添加数组的货币值之和我无法返回sum console.log(“total array sum”,+ array_sum); 这不是在控制台上enter image description here给出任何结果
function sumOfMonthsFullSeason(){
var promises = [];
var array_sum = 0;
for(var month_index = 6; month_index <= 25 ; month_index++){
const elm_xpath = utils.getXpathForSubCategory(chosen_season_index, month_index);
promises.push(element(by.xpath(elm_xpath)).getText());
}
return Promise.all(promises).then(function(data){
if (data != NaN){
for(var i = 0; i <=data.length; i++){
var array = parseFloat(data[i].replace(/[^?\d+(\.\d+)?]/g, ''));
array_sum += array;
console.log("sum of all months", + array_sum);
}
console.log("total array sum", + array_sum);
return array_sum;
}else{
return array_sum = 0;
}
});
};