all tools/JSON & Data/JSON Diff & Comparison
JSONJSON & Data

JSON Diff & Comparison

Compare two JSON payloads and inspect deep structural additions, modifications, and removals.

tool id:json-diff
original text (old)7 lines
modified text (new)6 lines
Unified Diff Viewer+5 lines-6 lines
1-function calculateTotal(items) {
1+function calculateTotal(items: CartItem[]): number {
2- let total = 0;
2+ // Use modern reduce with tax calculation
3- for (let i = 0; i < items.length; i++) {
3+ const subtotal = items.reduce((acc, item) => acc + item.price * item.quantity, 0);
4- total += items[i].price;
4+ const tax = subtotal * 0.08;
5- }
5+ return Number((subtotal + tax).toFixed(2));
6- return total;
76 }