function renderCards(data) {
let data1 = data;
let list = document.querySelector('.goods')
data1.forEach(function(item) {
let card = document.createElement("div");
card.classList.add("good");
let h2 = document.createElement("h2");
let img = document.createElement("img");
let p = document.createElement("p");
p.innerText = `${item.price}₽/кг`;
p.classList.add("good__price");
img.setAttribute("src", item.imgUrl);
img.classList.add("good__image");
h2.innerHTML = item.text;
h2.classList.add("good__description");
card.appendChild(h2);
card.appendChild(img);
card.appendChild(p);
if (item.inStock) {
card.classList.add("good--available");
} else {
card.classList.add("good--unavailable");
};
if (item.isHit) {
card.classList.add("good--hit");
let hitP = document.createElement("p");
hitP.innerText = item.specialOffer;
hitP.classList.add("good__special-offer");
card.appendChild(hitP);
};
list.appendChild(card);
})
}
renderCards(cardsData);