-
Notifications
You must be signed in to change notification settings - Fork 779
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
base: 13b
Are you sure you want to change the base?
13b Solution #4
Conversation
@@ -25,7 +25,7 @@ products.forEach((product) => { | |||
</div> | |||
<div class="product-quantity-container"> | |||
<select> | |||
<select class="js-quantity-selector-${product.id}"> |
There was a problem hiding this comment.
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,,,
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
No description provided.