Skip to content

Commit 7476340

Browse files
committed
Add Array.html file with examples of array and object iteration in JavaScript
1 parent 2d9c73b commit 7476340

File tree

1 file changed

+44
-0
lines changed
  • Example/Lectures/01 Lecture_Example/Basic

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 fruits = ["cherry", "banana", "apple"];
12+
13+
//for(i = 0 ; i <3 ; i++){
14+
// document.write("<li>",fruits[i],"</li>")
15+
//}
16+
17+
for(i in fruits){
18+
console.log(fruits[i])
19+
}
20+
21+
for(i of fruits){
22+
console.log(i)
23+
}
24+
25+
26+
const person = {
27+
firstName: "John",
28+
lastName: "Doe",
29+
age: 30
30+
};
31+
32+
for (let key in person) {
33+
console.log(key + ": " + person[key]);
34+
}
35+
36+
37+
38+
</script>
39+
40+
</head>
41+
<body>
42+
43+
</body>
44+
</html>

0 commit comments

Comments
 (0)