Skip to content

Commit 00a4ae0

Browse files
committed
feat: Block Chain Collage Code 1 - 14.2
1 parent cd3d482 commit 00a4ae0

2 files changed

Lines changed: 227 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
<a href="https://www.lamborghini.com/fr-en#val-ht">🏎</a>
10+
<img src="https://www.lamborghini.com/sites/it-en/files/DAM/lamborghini/0_facelift_2025/homepage/models/temerario/familyChooser-Temerario_0.png" alt="">
11+
<script src="script.js"></script>
12+
</body>
13+
</html>
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
// ECMA international
2+
3+
// ECMAScript === JavaScript
4+
5+
// Template string
6+
const fName = "Amin";
7+
const websiteName = "SpaceX";
8+
const hello = "Hello" + fName + "Welcome to our new" + websiteName + "!🎉";
9+
10+
const hello2 = `hello ${fName} welcome to our new ${websiteName} website !🎉`;
11+
12+
console.log(hello);
13+
console.log(hello2);
14+
15+
// ________________________________________________
16+
17+
let person = { name: "Sara", age: 25 };
18+
let { name, age } = person;
19+
console.log(`${name} is ${age} years old`);
20+
21+
// ________________________________________________
22+
23+
//Spread operator
24+
const animals = {
25+
tiger: 12,
26+
lion: 8,
27+
snake: 2,
28+
owl: 44,
29+
};
30+
31+
// const { tiger, ...rest } = animals;
32+
33+
function objectSpread(p1, p2, p3) {
34+
console.log(p1);
35+
console.log(p2);
36+
console.log(p3);
37+
}
38+
39+
const { tiger, lion, ...rest } = animals;
40+
41+
objectSpread(tiger, lion, rest);
42+
43+
// ________________________________________________
44+
45+
//Data type (Symbols)
46+
let sym1 = Symbol();
47+
let sym2 = Symbol("Amin");
48+
let sym3 = Symbol("Morteza");
49+
let sym4 = Symbol("Morteza");
50+
51+
console.log(sym2 === sym3);
52+
console.log(sym3 === sym4);
53+
54+
// ________________________________________________
55+
56+
//default arguments
57+
function greet(name = "", age = "", pet = "Cat") {
58+
name = "Amin";
59+
age = "19";
60+
return console.log(`Hi ${name} you are ${age} years old and you have a lovely ${pet}`);
61+
}
62+
63+
// ________________________________________________
64+
65+
//Arrow function
66+
function fa(a, b) {
67+
return a + b;
68+
}
69+
70+
const fa = (a, b) => {
71+
return a + b;
72+
};
73+
74+
const fa = (a, b) => a + b;
75+
76+
const fa = a => a;
77+
78+
// ________________________________________________
79+
80+
// let & const
81+
82+
// const player = "amin";
83+
// let experience = 100;
84+
// let wizard = false;
85+
86+
// if (experience > 90) {
87+
// wizard = true;
88+
// }
89+
90+
// console.log(wizard);
91+
92+
// player = "batman"; ❌
93+
94+
// console.log(player);
95+
96+
// const obj = {
97+
// player: "amin",
98+
// experience: 100,
99+
// wizard: false,
100+
// };
101+
102+
// obj = 5 // ❌
103+
104+
// obj.wizard = true; // ✅
105+
106+
// ________________________________________________
107+
108+
109+
// try {
110+
111+
// } catch {
112+
113+
// }
114+
115+
// catch()
116+
117+
// 1)
118+
function fail() {
119+
try {
120+
console.log("this works")
121+
throw new Error("ops!");
122+
console.log("this works");
123+
} catch (error) {
124+
// error parameter
125+
console.log("we have made and error", error);
126+
}
127+
}
128+
129+
fail(); // we have made and error Error: ops!
130+
131+
// ________________________________________________
132+
133+
// 2)
134+
// function fail() {
135+
// try {
136+
// console.log("this works")
137+
// } catch (error){ // error parameter
138+
// console.log("we have made and error")
139+
// }
140+
// }
141+
142+
// fail()
143+
144+
// ________________________________________________
145+
146+
// 3)
147+
function fail() {
148+
try {
149+
throw new Error("ops!");
150+
} catch (error) {
151+
// error parameter
152+
console.log("we have made and error", error.massage);
153+
} finally {
154+
console.log("this will always run");
155+
return "returning failed";
156+
}
157+
console.log("!!!!!!!! :)");
158+
}
159+
160+
fail();
161+
162+
// ________________________________________________
163+
164+
// function aminAge(age){
165+
// try{
166+
// let amin = 18
167+
// if(isNaN(amin)){
168+
// throw new Error("age is not valid!")
169+
// }
170+
// console.log("Your age:",amin)
171+
// }catch (error){
172+
// console.log("error",error.massage)
173+
// }
174+
// }
175+
176+
// aminAge()
177+
178+
// ________________________________________________
179+
180+
try {
181+
// This will throw an error because 'x' is not defined
182+
console.log(x);
183+
} catch (error) {
184+
console.log("An error occurred:", error.message);
185+
}
186+
187+
// ________________________________________________
188+
189+
async function main() {
190+
try {
191+
await x
192+
await y
193+
} catch (error) {
194+
console.log(err);
195+
}
196+
console.log("hey!");
197+
}
198+
199+
// ________________________________________________
200+
201+
async function fetchProduct() {
202+
try {
203+
const response = await fetch("https://fakestoreapi.com/products")
204+
if (!response.ok) {
205+
throw new Error("fetching data was unsuccessful!")
206+
}
207+
const data = await response.json();
208+
console.log("Products:", data)
209+
} catch (error) {
210+
console.log("Error:", error.massage)
211+
}
212+
}
213+
214+
fetchProduct()

0 commit comments

Comments
 (0)