forked from engindemirog/javaScriptStarterKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapFilterReduce.js
More file actions
35 lines (28 loc) · 1.01 KB
/
Copy pathmapFilterReduce.js
File metadata and controls
35 lines (28 loc) · 1.01 KB
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
34
35
let cart = [
{ id: 1, productName: "Telefon", quantity: 3, unitPrice: 4000 },
{ id: 2, productName: "Kupa", quantity: 5, unitPrice: 70 },
{ id: 3, productName: "Mouse", quantity: 10, unitPrice: 250 },
{ id: 4, productName: "Kulaklık", quantity: 15, unitPrice: 300 },
{ id: 5, productName: "Masa", quantity: 2, unitPrice: 1000 },
{ id: 6, productName: "Şarj Cihazı", quantity: 4, unitPrice: 150 },
]
console.log("<ul>")
cart.map(product => {
console.log("<li>" + product.productName + ":" + product.unitPrice * product.quantity + "</li>")
})
console.log("</ul>")
let total = cart.reduce((acc, product) => acc + product.unitPrice * product.quantity, 0)
console.log(total)
let quantityOver2 = cart.filter(product => product.quantity > 2)
console.log(quantityOver2)
function addToCArt(sepet) {
cart.push({ id: 7, productNamme: "Hırka", quantity: 1, unitPrice: 500 })
}
addToCArt(cart)
console.log(cart)
let sayi = 10
function sayiTopla(number) {
number += 1
}
sayiTopla(sayi)
console.log(sayi)