Skip to content

Add files via upload#8

Open
GAS53 wants to merge 1 commit intomainfrom
lesson_7
Open

Add files via upload#8
GAS53 wants to merge 1 commit intomainfrom
lesson_7

Conversation

@GAS53
Copy link
Copy Markdown
Owner

@GAS53 GAS53 commented Apr 20, 2022

No description provided.

Copy link
Copy Markdown

@Akseonov Akseonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

все отлично, молодец)

this.addProductToObject(product);
this.renderProductInBasket(product);
this.renderTotalSum();
this.addRemoveBtnsListeners();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нет такой функции

Comment on lines +1 to +2
let toBasketBtns = document.querySelectorAll('.toBasketBtn');
toBasketBtns.forEach(function (btn) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

обычно, если много элементов, то слушатель события вешается не на отдельную кнопку каждый, а на общий dom элемент и внутри делается проверка на какую именно кнопку произведен клик.

toBasketBtns.forEach(function (btn) {
btn.addEventListener('click', function (event) {
let id = event.srcElement.dataset.id;
let price = event.srcElement.dataset.price;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

обычно ссылаются на dom элемент event.target.dataset.id

Comment on lines +27 to +29
for (i=0;i<all_names.length;i++){
all_names[i].textContent = this.get_prod_name()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше использовать forEach

Comment on lines +51 to +55
let sum = 0;
for (let key in this.products) {
sum += this.products[key].price * this.products[key].count;
}
return sum;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше использовать reduce()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants