Text Compare (Diff)

Compare two text strings or code files side-by-side or inline to visually highlight additions, deletions, and edits.

Original Text (Old)

Modified Text (New)

Text Difference Output
+3 additions-5 deletions
function calculateTotal(items) {
- let total = 0;
- for (let i = 0; i < items.length; i++) {
- total += items[i].price;
- }
- return total;
+ return items.reduce((sum, item) => {
+ return sum + (item.price * (item.quantity || 1));
+ }, 0);
}