-
Notifications
You must be signed in to change notification settings - Fork 0
/
stript.js
28 lines (25 loc) · 1.13 KB
/
stript.js
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
document.addEventListener('DOMContentLoaded', function() {
// Assuming your JSON data is stored locally in a file named `data.json`
fetch('investments_data.json')
.then(response => response.json())
.then(data => {
displayData(data);
})
.catch(error => console.error('Error:', error));
});
function displayData(data) {
const container = document.getElementById('portfolioContainer');
let table = '<table><tr><th>Date</th><th>Ticker Symbol</th><th>Transaction Type</th><th>No. of Shares</th><th>Price per Share</th><th>Total Value</th></tr>';
data.forEach(item => {
table += `<tr>
<td>${item.Date}</td>
<td>${item['Ticker Symbol']}</td>
<td>${item['Transaction Type']}</td>
<td>${item['No. of Shares']}</td>
<td>${item['Price per Share USD']}</td>
<td>${(parseFloat(item['No. of Shares']) * parseFloat(item['Price per Share USD'].replace('$', ''))).toFixed(2)}</td>
</tr>`;
});
table += '</table>';
container.innerHTML = table;
}