Last active
September 27, 2016 13:42
-
-
Save rutger1140/c55c9322f2598f4a0cf3fd9a2d6a81ba to your computer and use it in GitHub Desktop.
Spotify total cost
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
var t = 0; | |
$(".receipt-price").each(function() { | |
// EU version - comma decimal separator | |
t += parseFloat($(this).text().substring(1).replace(',','.')); | |
// US version - dot decimal separator | |
// t += parseFloat($(this).text().substring(1)); | |
}); | |
console.log(t.toFixed(2)); |
The ES6 variant 😛
console.log(
Array.from(document.querySelectorAll(".receipt-price"))
.reduce( (total, el) => total += parseFloat(el.innerHTML.substring(1).replace(',','.')), 0)
.toFixed(2)
);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Want to know how much money you spend on Spotify?
Run this snippet it in your browsers console on the invoices page.