# VERDE quantity bug repair

A controlled, fictional bug-repair exercise. The demo shows a deliberately defective money-total function beside a corrected version and a local cart calculator that demonstrates the difference.

## Open the exercise

Double-click `bugfix/index.html` or open it directly in a modern browser. No server, package installation, or internet connection is required.

## Files

- `before.js` is the intentionally defective implementation and is preserved exactly as supplied.
- `after.js` is the corrected implementation.
- `index.html` displays both functions and provides an in-memory working demonstration.

## Defect and repair

The original function rounds `item.price` to cents but ignores `item.quantity`. The repair computes each unit price in cents and multiplies it by a validated quantity.

The corrected implementation rejects non-integer or negative quantities, non-number, non-finite, or negative prices, and malformed item objects. Quantity zero is allowed, as are zero prices, and an empty cart totals zero.

## Limitations

- This is an educational exercise, not a production incident or a complete commerce system.
- The page mirrors both function implementations in its embedded script so it works directly from `file://`; the JavaScript files remain the reference implementations.
- Cart data exists only in page memory and disappears on reload.
- Values are treated as decimal currency amounts and rounded to whole cents with JavaScript `Math.round`; this is not decimal-exact accounting software.
- No backend, network requests, storage, analytics, external assets, packages, or paid services are used.

## Checks

No automated checks, browser launches, or command-line executions were performed for this exercise, by explicit request. Independent unit, browser, and accessibility testing remains for the reviewer.
