Skip to content

Instantly share code, notes, and snippets.

@Salil999
Last active February 5, 2024 14:23
Show Gist options
  • Save Salil999/da98d58049f119735202b0f113b16180 to your computer and use it in GitHub Desktop.
Save Salil999/da98d58049f119735202b0f113b16180 to your computer and use it in GitHub Desktop.
Capital One Online Statement Summation
const computeTotal = () => {
const rows = document.querySelectorAll('c1-ease-row')
let total = 0
for(let i = 0; i < rows.length; i++) {
const amountString = rows[i].lastElementChild.innerText
if (amountString.charAt(0) === '-') {
// Negative amount -> need to subtract
// -$18.10
const amount = amountString.substring(2).replace(',', '')
console.log(amount)
total -= Number(amount)
} else {
// $42.34
const amount = amountString.substring(1).replace(',', '')
console.log(amount)
total += Number(amount)
}
}
console.log(total)
return total
}
computeTotal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment