Thanks to visit codestin.com
Credit goes to github.com

Skip to content

13b Solution #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 13b
Choose a base branch
from
Open

13b Solution #4

wants to merge 1 commit into from

Conversation

SuperSimpleDev
Copy link
Owner

No description provided.

@@ -25,7 +25,7 @@ products.forEach((product) => {
</div>
<div class="product-quantity-container">
<select>
<select class="js-quantity-selector-${product.id}">

Choose a reason for hiding this comment

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

I am confused, here is product.id, but on 13c and d has became productId,,,

Choose a reason for hiding this comment

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

product.id is used when we are creating the HTML for each product. It's available only in that part of the code.

productId is used inside the button click event because product.id isn't accessible there. productId comes from the button that was clicked, which tells you which product was selected.

Why the Change? because we use productId in the event listener to correctly identify and update the specific product when the "Add to Cart" button is clicked.

This ensures the right product is added to the cart when the button is clicked.

Choose a reason for hiding this comment

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

You were given correct direction to us sir!

Choose a reason for hiding this comment

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

why cant we use data attributes here ? and also can we use ${product.id} directly while adding the class name

Choose a reason for hiding this comment

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

yes @abhitejreddy you can use but then we need to add a event listener on select and then we need to change the value of the data attribute and then use the value in the other areas

Choose a reason for hiding this comment

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

Good day fellow developers I have a silly question that needs an answer. What files are we to copy into the folder: 13-javascript-amazon-projects folder. I really need an answer

Copy link

Choose a reason for hiding this comment

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

the whole javascript-amazon-projects folder including the changes

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.

8 participants