How to put the cards in container


To put the cards in the container, you can call the createCard function inside the forEach loop, passing each product object as an argument to the createCard function.

Please refer to the following code and try.If you have any other doubts means you can ask.

const container = document.getElementById(containerId);

products.forEach((product) => {
  // create card for each product
  const card = createCard(product);
  // put this card in container

function createCard(productInfo) {
  // create card element
  const card = document.createElement("div");

  // create image element
  const image = document.createElement("img");
  image.src = productInfo.imageSrc;

  // create name element
  const name = document.createElement("h3");
  name.textContent =;

  // create brand name element
  const brandName = document.createElement("h3");
  brandName.textContent = productInfo.brandName;

  // create price element
  const price = document.createElement("h3");
  price.textContent = productInfo.price;

  // append elements to card element

  // return the card element
  return card;

can please give me your linkdin id so can connect with

@dhanuchougule41 Sure!