Друзья, не могу найти ошибку - убилась искать. Ну что не так?
var makeElement = function(tagName, className, text) {
var element = document.createElement(tagName);
element.classList.add(className);
if (text) {
element.textContent = text;
}
return element;
};
var createCard = function(product) {
var listItem = makeElement(‘li’, ‘good’);
var title = makeElement(‘h2’, ‘good__description’, product.text);
listItem.appendChild(title);
var picture = makeElement(‘img’, ‘good__image’);
picture.src = product.imgUrl;
picture.alt = product.text;
listItem.appendChild(picture);
var price = makeElement(‘p’, ‘good__price’, product.price + ‘₽/кг’);
listItem.appendChild(price);
var availabilityClass = ‘good–available’;
if (!product.inStock) {
availabilityClass = ‘good–unavailable’;
}
listItem.appendChild(availabilityClass);
if(product.isHit) {
listItem.classList.add(‘good–hit’);
var HitMessage = makeElement(‘p’, ‘good__special-offer’, product.specialOffer);
listItem.appendChild(HitMessage);
}
return listItem;
};
var renderCards = function(array) {
var cardList = document.querySelector(’.goods’)
for (var i = 0; i < array.length; i++) {
var cardItem = createCard(array[i]);
cardList.appendChild(cardItem);
}
};
renderCards(cardsData);