I have this code and need to have it on a table but the table is not creating. What am I doing wrong?
<!DOCTYPE html> <html> <body> <script>
var investment = 2000;
var interest_rate = .12;
var deposit_amount = 100;
var start_age = 44;
var end_age = 65;
var beg_balance = 0;
var end_balance = 0;
var daily_interest_rate = interest_rate / 365;
var calculated_interest = 0;
var accrued_interest = 0;
var cumulative_deposits = 0;
var days = 0;
document.write("<table>")
document.write("<tr><th>Age</th><th>Beg Bal</th><th>Interest</th><th>Deposits</th><th>Ending Bal</th></tr>")
beg_balance = investment;
for (var yearly = start_age + 1; yearly <= end_age; yearly++)
{
for (var daily = 1; daily <= 365; daily++)
{
days++;
calculated_interest = (daily_interest_rate) * (beg_balance + cumulative_deposits + accrued_interest);
accrued_interest += calculated_interest;
if (days == 30)
{
days = 0;
cumulative_deposits += deposit_amount;
}
}
end_balance = beg_balance + cumulative_deposits + accrued_interest;
document.write("<tr>");
document.write("<td>" + yearly.toFixed(2) + "</td><td>" + beg_balance.toFixed(2) + "</td><td>" + accrued_interest.toFixed(2) + "</td><td>" + cumulative_deposits.toFixed(2) + "</td><td>" + end_balance.toFixed(2) + "</td>");
document.write("</tr>");
beg_balance = end_balance;
cumulative_deposits = 0;
accrued_interest = 0;
}
document.write("</table>")
</script>
// JavaScript Document
</body> </html>