Last active
January 24, 2019 01:06
-
-
Save DimaRGB/4da20fe0af6017cfbb3a6dcb341e4ec4 to your computer and use it in GitHub Desktop.
privat24: calculate expenses by regexp
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
// tab charts -> scroll down -> inspect table (iframe) | |
// taxi example | |
(function calculateExpenses(regexp) { | |
regexp = new RegExp(regexp, 'i'); | |
const allDescs = document.querySelectorAll('.t_descr'); console.log(allDescs); | |
const descs = Array.prototype.filter.call(allDescs, desk => regexp.test(desk.innerText)); console.log(descs); | |
const monies = descs.map(desk => +desk.nextSibling.childNodes[0].childNodes[0].innerText.slice(1)); console.log(monies); | |
const sum = monies.reduce((sum, money) => sum + money, 0); | |
return `${sum.toFixed(2)} грн`; | |
})('(таксі|taxi|uber|uklon)'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment