2
我試過DecimalFormat和parseFloat,兩者都不行。如何將循環Javascript程序格式化爲2位小數?
var NumOfOrganisms = 2;
var DailyIncrease = .30;
var NumOfDays;
console.log("Day" + '\t' + "Approximate Population");
console.log('1' + '\t' + NumOfOrganisms);
for(NumOfDays = 2; NumOfDays <= 10; NumOfDays++) {
NumOfOrganisms = NumOfOrganisms + (NumOfOrganisms * DailyIncrease);
console.log(NumOfDays + '\t' + NumOfOrganisms);
}
哇你真棒!謝謝 – agentmg123