// Demo code
window.sa5 = window.sa5 || [];
window.sa5.push(['datastoreLoaded',
(ds) => {
console.log("DATASTORE LOADED", ds.store['listings'].data);
// Initialize total
let total = 0;
let items = ds.store['listings'].data;
// Iterate through the map and sum the price field
items.forEach(item => {
total += parseFloat(item.price);
});
console.log(total);
const element = document.getElementById('portfolio-value');
if (element) {
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 0,
maximumFractionDigits: 0
});
element.innerText = formatter.format(total);
}
}]);