Skip to content

Add files via upload - #8

Open
GAS53 wants to merge 1 commit into
mainfrom
lesson_7
Open

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

Conversation

@GAS53

@GAS53 GAS53 commented Apr 20, 2022

Copy link
Copy Markdown
Owner

No description provided.

@Akseonov Akseonov left a comment

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 thread app.js
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 thread app.js
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 элемент и внутри делается проверка на какую именно кнопку произведен клик.

Comment thread app.js
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 thread app.js
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 thread app.js
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