-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL4T2.js
More file actions
33 lines (30 loc) · 804 Bytes
/
L4T2.js
File metadata and controls
33 lines (30 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
let basket = [
{
id: 1,
category: 'выпечка',
manufacturer: 'Фили Бэйкер',
name: 'торт',
price: 420,
quantity: 1
},
{
id: 2,
category: 'алкоголь',
manufacturer: 'Koor',
name: 'вино',
price: 750,
quantity: 3
},
{
id: 3,
category: 'товары для дома',
manufacturer: 'Да будет свет!',
name: 'свечи',
price: 59,
quantity: 5
}];
function countBasketPrice(basket) {
return basket.reduce((totalAmount, basketElem) => totalAmount += basketElem.price * basketElem.quantity, 0);
}
alert(`Стоимость вашей корзины = ${countBasketPrice(basket)}`);