-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathscript.js
More file actions
executable file
·75 lines (70 loc) · 2.15 KB
/
script.js
File metadata and controls
executable file
·75 lines (70 loc) · 2.15 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
/**
* Challenge: Create an advanced function.
* - Loop through backpackObjectArray to create an article with the class "backpack".
* - Give the article the ID of the current backpack object.
* - Set the inner HTML of the article to the existing HTML output provided in const content.
* - Append each backpack object to the <main> element.
*/
import Backpack from "./components/Backpack.js";
const backpackObjectArray = [
new Backpack(
"pack01",
"Everyday Backpack",
30,
"grey",
15,
26,
26,
false,
"December 5, 2018 15:00:00 PST",
"../assets/images/everyday.svg"
),
new Backpack(
"pack02",
"Hiking Backpack",
50,
"blue",
20,
30,
30,
true,
"January 1, 2020 10:00:00 PST",
"../assets/images/hiking.svg"
),
// Daha fazla sırt çantası nesnesi ekleyin
];
const main = document.querySelector(".maincontent");
backpackObjectArray.forEach((backpack) => {
const content = `
<figure class="backpack__image">
<img src=${backpack.image} alt="${backpack.name}" />
</figure>
<h1 class="backpack__name">${backpack.name}</h1>
<ul class="backpack__features">
<li class="packprop backpack__volume">Volume:<span> ${
backpack.volume
}l</span></li>
<li class="packprop backpack__color">Color:<span> ${
backpack.color
}</span></li>
<li class="backpack__age">Age:<span> ${backpack.backpackAge()} days old</span></li>
<li class="packprop backpack__pockets">Number of pockets:<span> ${
backpack.pocketNum
}</span></li>
<li class="packprop backpack__strap">Left strap length:<span> ${
backpack.strapLength.left
} inches</span></li>
<li class="packprop backpack__strap">Right strap length:<span> ${
backpack.strapLength.right
} inches</span></li>
<li class="feature backpack__lid">Lid status:<span> ${
backpack.lidOpen ? "open" : "closed"
}</span></li>
</ul>
`;
const newArticle = document.createElement("article");
newArticle.classList.add("backpack");
newArticle.setAttribute("id", backpack.id);
newArticle.innerHTML = content;
main.append(newArticle);
});