JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/AndrewWhitaker/jQuery-Aggregate/master/dist/jQuery-Aggregate.min.js"></script>
Total: <span id="total"></span>
JavaScript
var groceries = [
{ name: 'bread', price: 2.50 },
{ name: 'bologna', price: 4.00 },
{ name: 'cheddar cheese', price: 3.50 },
{ name: 'potato chips', price: 3.00 }
];
var total = $.sum(groceries, function () {
return this.price;
});
$("#total").text("$" + total);