Skip to content

Commit 5757259

Browse files
committed
update - array list using loop
1 parent da6bca6 commit 5757259

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

Example/Array/Food.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<script>
8+
data = ["Samosa",'kachori','Fafda','jalebi']
9+
10+
console.log(data);
11+
// access single item from array
12+
13+
console.log(data[1])
14+
15+
for (let index = 0; index < data.length; index++) {
16+
17+
console.log(data[index]);
18+
19+
}
20+
</script>
21+
</head>
22+
<body>
23+
24+
</body>
25+
</html>

Example/Array/Food_List.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
</head>
9+
<body>
10+
<ul id="print_food">
11+
<script>
12+
food = ['Samosa','kachori','jalebi','fafda','vadapav','Pav Bhaji']
13+
14+
p_food = document.getElementById("print_food");
15+
16+
for (let index = 0; index < food.length; index++) {
17+
18+
p_food.innerHTML += "<li>"+food[index]+"</li>";
19+
20+
}
21+
22+
</script>
23+
</ul>
24+
</body>
25+
</html>
26+
<style>
27+
ul{
28+
list-style: none;
29+
}
30+
li{
31+
padding: 10px;
32+
border: solid 1px black;
33+
width: 100px;
34+
text-align: center;
35+
margin: 10px;
36+
37+
}
38+
39+
</style>

0 commit comments

Comments
 (0)