# 我正在尝试从表格中将我的总数加在一起，但不知道如何去做

2023-01-06 09:36:41

<script>

// asks for the days you worked

var daysworked = parseFloat(prompt("daysworked", "100"));

//equation and table for the days worked

for (var days = 1; days <= daysworked; days++) {

document.write("<tr><td>"+ days +"</td>");

// here is specifically the equation and how i output it

document.write("<td>" + "\$" + ( Math.pow(2 , days - 1)*0.01) +"</td></tr>");

## 1 回答

DIEA

TA贡献1562条经验 获得超2个赞

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>");

}

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>");

• 1 回答
• 0 关注
• 10 浏览

0/150