-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpart2_4.html
More file actions
32 lines (28 loc) · 819 Bytes
/
Copy pathpart2_4.html
File metadata and controls
32 lines (28 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
<head>
<title>Part 2 - Compound Interest</title>
<style>
tr:nth-child(even) {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>Learn about Compound Interest</h1>
<div id="tables"></div>
<script>
const rates = [0.05, 0.06, 0.07];
for (let rate of rates) {
let tableHTML = `<table border="1"><thead><tr><th>Year</th><th>Amount on deposit</th><th>Interest Rate</th></tr></thead><tbody>`;
let P = 1000;
for (let year = 1; year <= 5; year++) {
let A = P * Math.pow((1 + rate), year);
tableHTML += `<tr><td>${year}</td><td>${A.toFixed(2)}</td><td>${rate}</td></tr>`;
}
tableHTML += `</tbody></table><br>`;
document.getElementById("tables").innerHTML += tableHTML;
}
</script>
</body>
</html>