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
42 lines (29 loc) · 1.06 KB
/
mapFilterReduce.js
File metadata and controls
42 lines (29 loc) · 1.06 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
36
37
38
39
40
41
//iterate edilebilen yapılara uygulanan fonksiyonlardır.
let cart = [
{id:1, productName:"Mouse", quantity:3, unitPrice:500},
{id:2, productName:"Keyboard", quantity:33, unitPrice:590},
{id:3, productName:"Pencil Case", quantity:13, unitPrice:52},
{id:4, productName:"Bag", quantity:23, unitPrice:510},
{id:5, productName:"Notebook", quantity:300, unitPrice:540},
{id:6, productName:"Laptop", quantity:3000, unitPrice:5000},
]
cart.map(product=>{
console.log(product.productName + " : " + product.unitPrice*product.quantity)
})
//SPA - single page application
//acc means accumulator which is the first value to start with
let total = cart.reduce((acc,product)=>acc + product.unitPrice * product.quantity,0)
console.log(total)
let quantityOver2 = cart.filter(product=>product.quantity>20)
console.log(quantityOver2)
function refTest(sepet){
sepet.push({id:7, productName:"Monitor", quantity:73, unitPrice:400})
}
refTest(cart)
console.log(cart)
let sayi = 10
function sayiTopla(number){
number+=1
}
sayiTopla(sayi)
console.log(sayi)