Adobe AEM
All tools

Developer Tool

Diff Checker.

Compare two blocks of text or JSON side-by-side with line-level (or structural, for JSON) diff highlighting. Runs entirely in your browser. How to use

+5-52 unchanged
Diff Options:
Unified Diff Preview
-function calculateTotal(items) {
- let total = 0;
- for (let i = 0; i < items.length; i++) {
- total += items[i].price;
+function calculateTotal(items, discount = 0) {
+ let total = items.reduce((sum, item) => sum + item.price, 0);
+ if (discount > 0) {
+ total = total - (total * (discount / 100));
}
- return total;
+ return Math.max(0, total);
}