forked from foocoding/JavaScript2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
184 lines (158 loc) · 3.49 KB
/
app.js
File metadata and controls
184 lines (158 loc) · 3.49 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
'use strict';
{
let games = [
{
title: 'stardew_valley',
year: '2016',
company: 'ConcernedApe',
type: 'role play',
image: 'images/stardewvalley.jpg'
},
{
title: 'overwatch',
year: '2016',
company: 'blizzard',
type: 'shooter',
image: 'images/overwatch.png'
},
{
title: 'lineage',
year: '2003',
company: 'NCSOFT',
type: 'MMORPG',
image: 'images/lineage.png'
},
{
title: 'counter_strike',
year: '2000',
company: 'namco',
type: 'shooter',
image: 'images/counterstrike.jpg'
},
{
title: 'wow',
year: '2004',
company: "blizzard",
type: 'role play',
image: 'images/wow.jpg'
},
{
title: 'house_of_the_dead',
year: '1996',
company: 'sega',
type: 'light gun shooter',
image: 'images/hotd.jpg'
}
]
document.body.onload = listGames;
function listGames() {
let ul = document.createElement('ul')
for (const game of games) {
let li = document.createElement('li');
li.innerHTML = `<h2>${game.title}</h2>`
li.innerHTML += `Year: ${game.year}<br>`
li.innerHTML += `Type: ${game.type}<br>`
li.innerHTML += `Company: ${game.company}<br>`
let cover = document.createElement("img");
cover.width = 250
cover.src = game.image;
li.appendChild(cover)
ul.appendChild(li);
}
document.body.appendChild(ul);
}
}
/* 'use strict';
document.body.style.backgroundColor = "#AA0054";
{
const gameTitles = [
'stardew_valley',
'overwatch',
'lineage',
'counter_strike',
'wow',
'house_of_the_dead'
];
let objGames = {
'stardew_valley': {
properties: {
year: '2016',
company: 'ConcernedApe',
type: 'role play',
image: 'stardewvalley.jpg'
},
},
'overwatch': {
properties: {
year: '2016',
company: 'blizzard',
type: 'shooter',
image: 'overwatch.png'
},
},
'lineage': {
properties: {
year: '2003',
company: 'NCSOFT',
type: 'MMORPG',
image: 'lineage.png'
},
},
'counter_strike': {
properties: {
year: '2000',
company: 'namco',
type: 'shooter',
image: 'counterstrike.jpg'
},
},
'wow': {
properties: {
year: '2004',
company: "blizzard",
type: 'role play',
image: 'wow.jpg'
},
},
'house_of_the_dead': {
properties: {
year: '1996',
company: 'sega',
type: 'light gun shooter',
image: 'hotd.jpg'
}
}
}
function listGamesOld() {
let ul = document.createElement('ul')
for (let i = 0; i < gameTitles.length; i++) {
let li = document.createElement('li');
li.textContent = gameTitles[i];
console.log()
ul.appendChild(li);
}
document.body.appendChild(ul);
}
document.body.onload = listGames;
function listGames() {
let i = 0;
let ul = document.createElement('ul')
let gameTitles = Object.keys(objGames);
let numberOfGames = gameTitles.length;
for (i = 0; i < numberOfGames; i++) {
console.log(gameTitles[i]);
console.log(objGames[gameTitles[i]]);
let li = document.createElement('li');
li.innerHTML = `<h2>${gameTitles[i]}</h2>`
li.innerHTML += `<li> Year: ${objGames[gameTitles[i]].properties.year} </li>`
li.innerHTML += `<li> Type: ${objGames[gameTitles[i]].properties.type} </li>`
li.innerHTML += `<li> Company: ${objGames[gameTitles[i]].properties.company} </li>`
let cover = document.createElement("img");
cover.src = objGames[gameTitles[i]].image;
li.innerHTML += `<img> ${document.getElementById("albumCovers").appendChild(cover)}`;
ul.appendChild(li);
}
document.body.appendChild(ul);
}
}
*/