# Unit of Measure Calculator

Update 4: Added a multi-buy multiplier field, in addition to highlighting any fields which are acting as multipliers.

Update 3: Added some regex to convert dollars into cents, e.g. $0.50 becomes 50¢.

Update 2: The workaround wasn't needed as it was my rounding function that was flawed to begin with; 0.4445 should never have been rounded up to 0.45 (yes I'm ashamed). Big thanks to Jack Moore and his rounding solution that replaced my ~30 line function with a single return statement.

Update 1: Added a dirty workaround for floating point rounding, e.g. 0.4444 repeating became 0.4445 which inadvertently triggered my rounding function.

Our team often needs to find the unit of measure for a product, so I've made a calculator to speed things up (and ensure we don't make any errors!)

The first version was quickly pieced together as a proof of concept, which was in use for several months. When I revisited the code to add another option to a dropdown, I decided to completely rewrite it to take advantage of the template rendering of Underscore.js and restyled the page with Bootstrap 3 while I was at it.

As an added bonus, I've added a Savings Calculator which shows how much is saved as a percentage of the original price (rounded down to the nearest 5% as that is how we operate at my workplace).

Take a look below!

See the Pen Pricing Calculators by Mitch Ray (@mitchray) on CodePen.