Skip to content

Instantly share code, notes, and snippets.

@ethnt
Created January 12, 2019 23:40
Show Gist options
  • Save ethnt/2b06e3c00c9dbafa1870cc2246bb36b3 to your computer and use it in GitHub Desktop.
Save ethnt/2b06e3c00c9dbafa1870cc2246bb36b3 to your computer and use it in GitHub Desktop.
Aspiration current balance
var available = parseFloat(document.querySelector('.balance .numbers').innerHTML.replace('$', ''));
var pendingTransactionValues = Array.prototype.slice.call(document.querySelectorAll('.transaction-row.pending')).map(element => element.querySelector('.value .amount').innerHTML.split('$'));
var total = 0.0;
values.forEach(function (arr) {
var sign = arr[0];
var value = parseFloat(arr[1]);
if (sign === "-") {
total += value
} else {
total -= value
}
});
var currentBalance = available + total;
alert("Current balance: " + currentBalance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment