Apologies for the potentially silly question - I'm fairly new to coding/JavaScript.
I am using Plaid's sandbox environment to pull in transactional data in a sandbox environment. Right now, I define the following as transactionData:
let transactionsData = [];
transactions.forEach(function(account) {
account.transactions.forEach(function(transaction) {
transactionsData.push({
account: account.accountName,
date: transaction.date,
category: transaction.category[0],
name: transaction.name,
amount: transaction.amount
});
});
});
I can successfully render the individual transactions row by row in a material table like so:
const transactionsColumns = [
{ title: "Account", field: "account" },
{ title: "Date", field: "date", type: "date", defaultSort: "desc" },
{ title: "Name", field: "name" },
{ title: "Amount", field: "amount", type: "numeric" },
{ title: "Category", field: "category" }
];
<MaterialTable
columns={transactionsColumns}
data={transactionsData}
}}
I know this has to be super simple, but all I want to do is sum the transactionsData and render that single summed value elsewhere on my page. If I write transactionsData.length I can receive the count of the transactions quite easily. I have tried the following somewhat similar syntax but have not found it to work:
array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
Any help would be much appreciated.