1 回答

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超3個(gè)贊
也許這會(huì)給你一個(gè)提示:
var earningsPerDay = 77;
var totalEarnings = 0;
for (var days = 1; days <= daysworked; days++) {
totalEarnings = totalEarnings + earningsPerDay;
document.write("<tr><td>"+ days +"</td>");
document.write("<td>" + "$" + totalEarnings +"</td></tr>");
}
更新
經(jīng)過您的解釋,這里有一個(gè)更好的答案:
var totalEarnings = 0;
for (var days = 1; days <= daysworked; days++) {
todaysEarnings = Math.pow(2 , days - 1) * 0.01;
totalEarnings = totalEarnings + todaysEarnings;
document.write("<tr><td>"+ days +"</td>");
document.write("<td>" + "$" + todaysEarnings +"</td></tr>");
}
document.write("<tr><td>" + "Total: $" + totalEarnings +"</td></tr>");
要么:
document.write("<td>" + "$" + todaysEarnings +"</td><td>" + totalEarnings + "</td></tr>");
添加回答
舉報(bào)