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
95 lines (73 loc) · 2.25 KB
/
function.js
File metadata and controls
95 lines (73 loc) · 2.25 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
function addToCart(productName, quantity) {
console.log("Sepete Eklendi: " + productName + " Adet: " + quantity);
}
addToCart("Elma", 5);
let sayHello = () => {
console.log("Hello World!");
};
sayHello();
let sayHello2 = function () {
console.log("Hello World 2");
};
sayHello2();
function addToCart2(productName, quantity, unitPrice) {}
addToCart2("Elma", 3, 10);
addToCart2("Armut", 5, 6);
let product1 = { productName: "Elma", unitPrice: 10, quantity: 5 };
function addToCart3(product) {
console.log("Ürün: " + product.productName);
console.log("Adet: " + product.quantity);
console.log("Fiyat: " + product.unitPrice);
}
addToCart3(product1);
let product2 = { productName: "Elma", unitPrice: 10, quantity: 5 };
let product3 = { productName: "Elma", unitPrice: 10, quantity: 5 };
product2 = product3;
product2.productName = "Karpuz";
console.log(product3.productName);
let sayi1 = 10;
let sayi2 = 15;
sayi1 = sayi2;
sayi2 = 20;
console.log(sayi1);
function addToCart4(x) {
console.log(x);
}
let products = [
{ productName: "Elma", unitPrice: 10, quantity: 5 },
{ productName: "Armut", unitPrice: 10, quantity: 5 },
{ productName: "Karpuz", unitPrice: 10, quantity: 5 },
];
addToCart4(products);
function add(bisey, ...numbers) {
//rest operatöründe ... yazılırsa önüne gelir. başka bir şey tanımlanırsa ondan önce yazılır. etc. (bisey,...numbers)
let total = 0;
for (let i = 0; i < numbers.length; i++) {
total = total + numbers[i];
}
console.log(total);
console.log(bisey);
}
add(20, 30);
//add(20, 30, 40);
//add(20, 30, 40, 50);
let numbers = [30, 60, 78, 344, 51, 533];
console.log(numbers);
console.log(...numbers);
console.log(Math.max(...numbers));
let [icAnadolu, marmara, karadeniz, [icAnadoluSehirleri]] = [
{ name: "İç Anadolu", population: "20M" },
{ name: "Marmara", population: "30M" },
{ name: "Karadeniz", population: "15M" },
[["Ankara", "Konya"], ["İstanbul", "Bursa"][("Trabzon", "Ordu")]],
];
console.log(icAnadoluSehirleri);
let newProductName, newUnitPrice, newQuantity;
({
productName: newProductName,
unitPrice: newUnitPrice,
quantity: newQuantity,
} = { productName: "Elma", unitPrice: 10, quantity: 5 });
console.log(newProductName);
console.log(newUnitPrice);
console.log(newQuantity);