-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayExercise.html
More file actions
64 lines (43 loc) · 1.54 KB
/
arrayExercise.html
File metadata and controls
64 lines (43 loc) · 1.54 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
<!DOCTYPE html>
<html>
<head>
<title>Hostel Reservations
</title>
<link rel="stylesheet" href="CSS/global.css">
<script src="JS/global.js"></script> <!-- external js file -->
<link rel="stylesheet" href="Bootstrap/css/bootstrap.min.css">
<script src="Bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="Bootstrap/Jquery/jquery-3.6.0.min.js"> </script>
<link rel="stylesheet" href="Bootstrap/fontawesome-free-5.15.3-web/css/all.css">
<script type="text/javascript">
var array = [[1, 5, 8], ["hello", "hi"], 4, 5]
console.log(array);
console.log(array[1]);
console.log(array.length);
//use push method to add elements at end of array
console.log(array.push("javascript"));
console.log(array);
//pop remove element at first place
console.log(array.pop());
console.log(array);
var donuts = ["glazed", "strawberry frosted", "powdered", "Boston creme"];
donuts.pop();
donuts.pop();
donuts.pop();
donuts.push("maple walnut");
donuts.pop();
donuts.push("sprinkled");
console.log(donuts);
var donuts = ["glazed", "chocolate frosted", "Boston creme", "glazed cruller"];
donuts.splice(1, 1, "chocolate cruller", "creme de leche");
console.log(donuts);
donuts.forEach(function (donuts) {
donuts += "hello";
console.log(donuts);
});
</script>
</head>
<body>
<h2>JavaScript</h2>
</body>
</html>