You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.6 KiB
70 lines
2.6 KiB
<!doctype html> |
|
<html> |
|
<head> |
|
<meta charset="utf-8"> |
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
<title>My Learning Website</title> |
|
<link href="/styles/styles.css" rel="stylesheet" type="text/css"> |
|
<link href="/webdevelopment/styles/styles.css" rel="stylesheet" type="text/css"> |
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> |
|
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> |
|
<!--[if lt IE 9]> |
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> |
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> |
|
<![endif]--> |
|
</head> |
|
|
|
<body id="homebody"> |
|
<div class="header"> |
|
<h1>The script.js file from Challenge: Build an Advanced Function</h1> |
|
</div> |
|
<pre class="codesample"> |
|
import backpackObjectArray from "./components/data.js"; |
|
|
|
const article = document.querySelector("main"); |
|
|
|
// map() through the stuff array to make a new stuffItems array. |
|
const packList = backpackObjectArray.map((item) => { |
|
const content = ` |
|
<figure class="backpack__image"> |
|
<img src=${item.image} alt="" loading="lazy" /> |
|
</figure> |
|
<h1 class="backpack__name">${item.name}</h1> |
|
<ul class="backpack__features"> |
|
<li class="feature backpack__volume">Volume:<span> ${ |
|
item.volume |
|
}l</span></li> |
|
<li class="feature backpack__color">Color:<span> ${ |
|
item.color |
|
}</span></li> |
|
<li class="feature backpack__age">Age:<span> ${item.backpackAge()} days old</span></li> |
|
<li class="feature backpack__pockets">Number of pockets:<span> ${ |
|
item.pocketNum |
|
}</span></li> |
|
<li class="feature backpack__strap">Left strap length:<span> ${ |
|
item.strapLength.left |
|
} inches</span></li> |
|
<li class="feature backpack__strap">Right strap length:<span> ${ |
|
item.strapLength.right |
|
} inches</span></li> |
|
<li class="feature backpack__lid">Lid status:<span> ${ |
|
item.lidOpen ? "open" : "closed" |
|
}</span></li> |
|
</ul> |
|
`; |
|
|
|
console.log("Item is :", item); |
|
console.log("Contents are: ", content); |
|
|
|
const backpack_div = document.createElement("div"); |
|
backpack_div.innerHTML = content; |
|
return backpack_div; |
|
|
|
}); |
|
|
|
packList.forEach((item) => { |
|
article.append(item) |
|
});</pre> |
|
</body> |
|
</html>
|
|
|