Skip to content

Instantly share code, notes, and snippets.

@briandipalma
Created April 24, 2020 13:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save briandipalma/d71e7b23eff4b0d71abd61c2cf5dc02b to your computer and use it in GitHub Desktop.
var getAmount = (e) => e.querySelector(".text-right").innerText.replace("€", "");
var parse = e => parseFloat(getAmount(e));
var tbody = document.querySelector(".transactions-data-table tbody");
var entries = Array.from(tbody.children);
var amounts = entries.map(parse);
var mostRecentYearly = amounts.indexOf(110.00);
var lastYearly = amounts.indexOf(110.00, mostRecentYearly + 1);
var yearlyCharges = amounts.slice(mostRecentYearly, lastYearly);
yearlyCharges.reduce((a, v) => a + v, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment