Skip to content

Commit 83fc577

Browse files
author
Potecaru Tudor
committed
Updated to calculate the correct total price.
1 parent eb8ece9 commit 83fc577

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: Classes/00. Product Inventary Project.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
getTotalPrice : function () {
5252
var sum = this.items.reduce(function (previousValue, currentValue, index, array) {
53-
return previousValue + currentValue.price;
53+
return previousValue + currentValue.price * currentValue.quantity;
5454
}, 0);
5555

5656
return sum;
@@ -62,5 +62,5 @@
6262
bananas = new Product(2, "bananas", 6, 3000),
6363
inventary = new Inventary(peaches, carrots, bananas);
6464

65-
inventary.getTotalPrice();
65+
return inventary.getTotalPrice();
6666
}());

0 commit comments

Comments
 (0)