here is my sample code
<body>
<div id="root">
<div class ="product" data-item-id="product">
<img src="assets/images/iphone-se.jpeg" class="product__image">
<h3 class="product__name">...</h3>
<p class="product__description">...</p>
<h4 class="product__price">...</h4>
<div class="product__tags">
red
blue
black</div>
</div>
</div>
<script src="assets/data.js"></script>
<!-- defer specifies that the script is executed when the page has finished parsing. -->
<script src="assets/index.js" defer></script>
<!-- Example of an inline script -->
<script>
document.addEventListener('DOMContentLoaded', () => {
console.log('Rendering All Cards ....');
renderAllCards(productList);
});
console.log(productList);
</script>
</body>
this is my data.js file code
const productList = [
{
id: 1,
name: 'PlayStation 5',
description: 'Next generation PlayStation from Sony packing the latest AMD Zen CPUs',
image: 'assets/images/ps5.jpeg',
price: 39999,
memory: '8 GB',
storage: '2 TB',
colors: ['blue', 'black', 'red']
},
{
id: 2,
name: 'PlayStation 4',
description: 'Last generation PlayStation from Sony with older generation Intel CPUs',
image: 'assets/images/ps4.jpeg',
price: 29999,
memory: '4 GB',
storage: '1 TB',
colors: ['yellow', 'black', 'red']
},];
window.productList = productList;
What I have tried:
i am stuck please help
function renderAllCards(card) {
const renderRoot= document.querySelectorAll("#root");
renderRoot.innerHTML = 'card';
}