From 62311d579b231d0299df33b26ed366969d97b7bc Mon Sep 17 00:00:00 2001 From: nxn Date: Tue, 26 Apr 2022 00:14:30 +0300 Subject: [PATCH] home work 2 --- Lesson2/project/js/main.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Lesson2/project/js/main.js b/Lesson2/project/js/main.js index c8a22ba..a6c4ba6 100644 --- a/Lesson2/project/js/main.js +++ b/Lesson2/project/js/main.js @@ -5,7 +5,7 @@ class ProductList { this._productsObjects = []; this._fetchGoods(); this._render(); - + this.getAllGoodsPrice(); } _fetchGoods() { @@ -27,6 +27,15 @@ class ProductList { } } + getAllGoodsPrice(){ + let sum = 0; + for (const goods of this._goods) { + + sum += goods.price; + } + console.log(`Суммарная стоимость продуктов ${sum}`); + return sum; + } }