Skip to content

Commit a1745dd

Browse files
committed
objects ... update
1 parent b309ad3 commit a1745dd

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed

Lectures/Lecture02/6 Jan 2025 - Functions/Function_example.html renamed to Lectures/Lecture02/6 Jan 2026 - Functions/Function_example.html

File renamed without changes.
File renamed without changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
8+
<script>
9+
10+
function bill() {
11+
12+
tax = 190;
13+
14+
function calculateTax() {
15+
let price = 1000;
16+
console.log(tax+price);
17+
}
18+
19+
calculateTax();
20+
21+
22+
console.log(tax);
23+
24+
25+
}
26+
27+
bill();
28+
</script>
29+
30+
</head>
31+
<body>
32+
33+
</body>
34+
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
8+
<script>
9+
10+
function bill() {
11+
12+
tax = 190;
13+
14+
function calculateTax() {
15+
let price = 1000;
16+
console.log(tax+price);
17+
}
18+
19+
calculateTax();
20+
21+
22+
console.log(tax);
23+
24+
25+
}
26+
27+
bill();
28+
</script>
29+
30+
</head>
31+
<body>
32+
33+
</body>
34+
</html>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
8+
<script>
9+
10+
11+
const info = {
12+
name: "Alice",
13+
age: 30,
14+
city: "New York"
15+
}
16+
17+
console.log(info.name);
18+
19+
console.log(info);
20+
21+
console.log(info['age']);
22+
23+
// get all keys
24+
console.log(Object.keys(info));
25+
26+
// for loop
27+
for (let key in info) {
28+
console.log(key + ": " + info[key]);
29+
}
30+
31+
// other way
32+
33+
for(i = 0 ;i < 3; i++) {
34+
keys = Object.keys(info)[i]
35+
console.log(keys + ": " + info[keys]);
36+
}
37+
38+
39+
40+
// other example
41+
42+
const student = {
43+
firstName: "Alice",
44+
lastName: "Smith",
45+
age: 20,
46+
greet: function() {
47+
console.log("this is info about student:");
48+
}
49+
};
50+
51+
student.greet(); // "Hello, I'm Alice Smith."
52+
53+
</script>
54+
55+
</head>
56+
<body>
57+
58+
</body>
59+
</html>

0 commit comments

Comments
 (0)