forked from engindemirog/javaScriptStarterKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.js
More file actions
129 lines (88 loc) · 2.85 KB
/
function.js
File metadata and controls
129 lines (88 loc) · 2.85 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
function addToCart(quantity, productName = "Elma") {
console.log("Sepete Eklendi : ürün : " + productName + " adet : " + quantity)
}
//addToCart()
//addToCart("Yumurta")
//addToCart("Karpuz")
addToCart(10)
let sayHello = () => {
console.log("Hello World");
}
sayHello()
let sayHello2 = function() {
console.log("Hello World");
}
sayHello2()
function addToCart2(productName, quantity, unitPrice) {
console.log("Ürününüz: " + productName + "Kaç tane seçtiniz: " + quantity + "," + unitPrice);
}
addToCart2("Elma", 5, 10)
addToCart2("Armut", 2, 20)
addToCart2("Limon", 3, 15)
function addToCart3(product) {
console.log("Ürün:" + product.productName + "Ürün adedi: " + product.quantity, "Fiyatı: " + product.unitPrice);
}
let product1 = { productName: "Elma ", unitPrice: "5", quantity: "10" }
addToCart3(product1)
let product2 = { productName: "Elma ", unitPrice: "5", quantity: "10" }
let product3 = { productName: "Elma ", unitPrice: "5", quantity: "10" }
//içindeki değerler değil adres ataması yapılmıştır.
product2 = product3
product2.productName = "KARPUZ"
console.log(product3.productName)
function addToCart4(products) {
console.log(products);
}
let products = [
{ productName: "Elma ", unitPrice: "5", quantity: "10" },
{ productName: "Armut ", unitPrice: "5", quantity: "10" },
{ productName: "Karpuz ", unitPrice: "5", quantity: "10" }
]
addToCart4(products)
function add(number1, number2) {
console.log(number1 + number2)
}
add(30, 20)
function add2(...numbers) { //rest operatorü nedir 3 noktalı hale
let total = 0
for (let i = 0; i < numbers.length; i++) {
console.log(numbers[i])
total = total + numbers[i]
}
console.log(total)
}
add2(20, 30, 40, 50)
let numbers = [30, 20, 10, 100, 500, 200, 15, 120, 600]
//console.log(Math.max(numbers))//Math.max ayrı ayrı sayılarla çalıştığı için hata verecektir.
console.log(Math.max(...numbers))
let regions = ["İç Anadolu", "Marmara", "Karadeniz"]
console.log(regions[1])
//Yerine
/*
let [icAnadolu, marmara, karadeniz] = [
"İç Anadolu",
"Marmara",
"Karadeniz"
]
console.log(icAnadolu)
console.log(marmara)
*/
//Obje kullanalım
let [icAnadolu, marmara, karadeniz, [icAnadoluSehirleri]] = [
{ name: "İç Anadolu", population: "20M" },
{ name: "Marmara", population: "30M" },
{ name: "Karadeniz", population: "10M" },
[
["Ankara", "Konya"],
["İstanbul", "Bursa"],
["Sinop", "Trabzon"],
]
]
//console.log(icAnadolu.name)
//console.log(icAnadolu.population)
console.log(icAnadoluSehirleri);
let newProductName, newUnitPrice, newQuantity
({ pruductName: newProductName, unitPrice: newUnitPrice, quantity: newQuantity } = { pruductName: "Elma", unitPrice: 10, quantity: 5 })
console.log(newProductName)
console.log(newUnitPrice);
console.log(newQuantity);