Skip to content

Instantly share code, notes, and snippets.

@lnaia
Created January 26, 2017 09:25
Show Gist options
  • Save lnaia/48e94ded62f62dd7f120c1d015466c56 to your computer and use it in GitHub Desktop.
Save lnaia/48e94ded62f62dd7f120c1d015466c56 to your computer and use it in GitHub Desktop.
(function () {
var accumulator = 0;
$('.Billing--history tr td').map(function (i, el) {
var text = el.innerText.trim();
var r = /^-\$?[0-9]+(\.[0-9][0-9])?$/;
var number;
if (text) {
number = text.match(r);
if (number) {
number = number[0];
if (number[0] === "-") {
number = number.slice(1);
}
if (number[0] === "$") {
number = number.slice(1);
}
accumulator += parseFloat(number);
console.log(accumulator);
}
}
});
console.log("final result: ", accumulator);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment