Code Diff & Patch Inspector

CodeStable
Lines Added
+4
Lines Removed
-5
Unchanged Lines
2
Code Similarity
22%
Diff Output
1-function calculateTotal(items) {
2- var total = 0;
3- for (var i = 0; i < items.length; i++) {
4- total = total + items[i].price;
1+function calculateTotal(items: CartItem[]): number {
2+ if (!items || items.length === 0) {
3+ return 0;
54 }
6- return total;
5+ return items.reduce((acc, curr) => acc + (curr.price * curr.quantity), 0);
76 }
11 total diff lines generatedClient-Side LCS Engine