Skip to content

Instantly share code, notes, and snippets.

@Daronspence Daronspence/mehTotal.js
Last active Aug 5, 2016

What would you like to do?
Calculate Total
// Run this is the JS console of your Browser.
// jQuery must be loaded
var total = 0;
$('span.summary').each(function() {
// Get the QTY and Purchase Price
var nums = $(this).text().match(/\d+\.\d+|\d+\b|\d+(?=\w)/g);
// Multiply QTY by Purchase Price
total += parseInt(nums[0],10)*parseInt(nums[nums.length - 1],10);
alert("Your Meh habit has cost you $" + total + " so far");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.