Skip to content

Instantly share code, notes, and snippets.

@stephen-lazaro
Created October 4, 2018 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephen-lazaro/d7bed172a69cab87943fc442da254ab4 to your computer and use it in GitHub Desktop.
Save stephen-lazaro/d7bed172a69cab87943fc442da254ab4 to your computer and use it in GitHub Desktop.
const getAggregates = report => {
// Announce… uh, a lot of goals
  let sumOfBalance = 0;
  let count = 0;
  let sumOfInterest = 0;
  let numberInRepayment = 0;
  // …20 other declarations here…
  let obscureCalculation = 0;
report.forEach(function (record) {
  // A lot of updates?
  sumOfBalance += record.balance;
  count += 1;
  sumOfInterest += record.interest;
  numberInRepayment += record.inRepayment ? 1 : 0;
  // .. 20 other calculations here…
  obscureCalculation = insaneProcedure(obscureCalculation, record)
  });
// Return a huge object
  return {
  totalBalance: sumOfBalance,
  // … 23 other keys here …
  length: count
  };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment