Skip to content

Conversation

@IgoryanM
Copy link
Owner

No description provided.

Comment on lines +78 to +93
for (let i in this.goods) {
if (goodTitle == this.goods[i].title) {
if (cart.goodsInCart.length == 0) cart.goodsInCart.push(this.goods[i]);
else {
for (let j in cart.goodsInCart) {
if (cart.goodsInCart[j].title == goodTitle) {
cart.goodsInCart[j].quantity += 1;
goodInCart = true;
}
}
if (goodInCart == false) cart.goodsInCart.push(this.goods[i]);
};
};
};
}

Copy link

Choose a reason for hiding this comment

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

дороговатое решение, посмотрите в сторону метода find у массива

Comment on lines +97 to +98
catalog.init();
cart.init();
Copy link

Choose a reason for hiding this comment

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

чтобы не завязываться на внешние данные, лучше передать ссылку на каталог в init каталога и сохранить внутри объекта, чтобы далее весь код опирался именно на this.cart

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.

3 participants