0

我正面临一个 nodeJS 8.10 片段的奇怪问题。

考虑以下对象:

installments: {
    baseAmount: 294,
    expired: 304,
    settle: 2697
}

现在我有以下片段

let amount
const amountChoice = choice.text //comes as string
...
switch (amountChoice) {
  case '1':
    amount = installments.baseAmount
    console.log(installments.baseAmount)
    console.log(amount)
    console.log(typeof installments.baseAmount)
    console.log(typeof amount)
    break
....

现在对于奇怪的部分,console.log 行打印如下

294 // installments.amount
undefined // amount
undefined // typeof installments.amount
undefined // typeof amount

我试图解析分期付款的 parseInt 和 toString ,但两者都抛出 NaN 异常或无法 toString 未定义。

这让我发疯!我刚刚发现了一个错误还是什么?

4

0 回答 0