ループ内の別の数値に 0.1 を追加しているときに、奇妙なことが起こっています。
function updateLoop() {
for (var key in resources) {
if (resources.hasOwnProperty(key)) { // Key is "Population" here.
// Add income to stock.
resources[key][1] += resources[key][0];
document.getElementById(key).innerHTML = resources[key][1];
}
}
setTimeout(updateLoop, 3000);
}
何らかの理由で、0.1 を追加する代わりに、オブジェクト
内に0.1000000000000001 を追加することがあります。resources
Population: Array[2]
0: 0.1
1: 1.2000000000000002
なぜこれが起こるのか誰にも分かりますか?直せますか?