由数组成员乘以获取新数组

时间:2013-10-10 07:54:23

标签: javascript google-apps-script

function cleanPayment() {
  var budget = sheet.getRange(1,6,1,1).getValue();
  var cardsTotal = 0;
  for (var i = 0; i < cards.length; i++) {
    cardsTotal += Number(cards[i]);
    var perCard = budget / cardsTotal;
    var payments = [];
    payments.push(cards[i] * perCard);
  }
Logger.log(payments);
}

payments应该包含一个数组,不是吗?但是Logger.log(payments)会返回单个数字。 smb看错了吗?

提前谢谢。

1 个答案:

答案 0 :(得分:1)

尝试在var payments = [];循环

之外声明for