Skip to content

Lesson 6#3

Open
AlexPL2201 wants to merge 2 commits intomainfrom
Lesson_6
Open

Lesson 6#3
AlexPL2201 wants to merge 2 commits intomainfrom
Lesson_6

Conversation

@AlexPL2201
Copy link
Copy Markdown
Owner

No description provided.

Comment thread Ex_1/script.js
this.addEventHandlers();
},

addProduct() {
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 Ex_1/script.js

addToCart(product) {
const productChecked = this.cart.find(productCheck => productCheck.id == product.id);
if (productChecked == undefined) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if (!productChecked)

Comment thread Ex_1/script.js
Comment on lines +73 to +74
product.count = 1;
this.cart.push(product);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

product.count = 1;
this.cart.push({...product, count: 1});

Comment thread Ex_1/script.js
if (!event.target.classList.contains('btn')) return;
const productId = event.target.dataset.id;
const product = this.products.find(product => product.id == productId);
myCart.addToCart(product);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

завязка на глобальную переменную myCart

Comment thread Ex_1/script.js
this.showCart();
},

showCart() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

генерацию разметки лучше делать через шаблонные строки

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