Last active
February 5, 2024 14:23
-
-
Save Salil999/da98d58049f119735202b0f113b16180 to your computer and use it in GitHub Desktop.
Capital One Online Statement Summation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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