-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample02.html
38 lines (35 loc) · 976 Bytes
/
example02.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Populating an Array with Data</title>
<style>
body {
margin: 1em;
font-size: 1.5em;
}
div {
margin-top: .5em;
}
img {
width: 400px;
}
</style>
</head>
<body>
<div id="output">
</div>
<script>
// Declare the array
const dogPhotos = new Array(5);
// Initialize the array values
dogPhotos[0] = "dog-1";
dogPhotos[1] = "dog-2";
dogPhotos[2] = "dog-3";
dogPhotos[3] = "dog-4";
dogPhotos[4] = "dog-5";
// Display an example
document.getElementById('output').innerHTML = '<img src="images/' + dogPhotos[0] + '.png" alt="">';
</script>
</body>
</html>