我似乎无法在我的代码中使currentCost [0]或buildingA增加。为什么我不能更改变量?
我的问题可能是在这里:
{
document.getElementById("costA").innerHTML = currentCost[0]
document.getElementById("amountA").innerHTML = buildingA
document.getElementById("canPay").innerHTML = "You just bought another!"
count.postMessage({action:'subtract', amount:currentCost[0], once:true});
currentCost[0] = Math.ceiling(nlogn(currentCost[0]+1)) + 5
buildingA = buildingA + 1
}
这是一个if语句中。
我的目标是当建筑物被购买时,它会增加一个存在的类型的建筑物的数量,并根据预定的功能,即newPrice = oldPrice*log10(oldPrice)
增加价格。
但是,当我购买建筑A时,价格将保持在15,并且它总是说我有0 buildingA's。
你应该在这里发布你的源代码,而不是链接到你的整个存储库。这里的代码发布应该是[MCVEs](http://stackoverflow.com/help/mcve) – ray