Filter and Summarize
Totals Footer
Quantity and price columns are multiplied per row and then reduced into a table footer total.
Program
CSV-backed tables can show both source rows and computed summaries. The footer should come from data, not hand-entered totals.
totals_footer.html
<script>
const rows = [
{ item: "Cable", qty: 3, price: 12.50 },
{ item: "Hub", qty: 1, price: 39.00 }
];
const lineTotals = rows.map(row => row.qty * row.price);
const total = lineTotals.reduce((sum, value) => sum + value, 0);
renderWithFooter(rows, total);
</script>
map
map derives one computed value for each source row.
reduce
reduce combines many values into one summary value.