Design comparison
SolutionDesign
Solution retrospective
What are you most proud of, and what would you do differently next time?
I learned how to handle product counts, unique product lists, and total price calculations in a shopping cart context using JavaScript. Here's a breakdown of what I implemented:
// Calculate the count of each product const productCounts = selectedProducts.reduce((acc, product) => { acc[product.name] = (acc[product.name] || 0) + 1; return acc; }, {} as Record); // Create a list of unique products with their counts const uniqueProducts = selectedProducts.reduce((acc: Product[], product) => { if (!acc.find(p => p.name === product.name)) { acc.push(product); } return acc; }, []); // Calculate total price const totalPrice = selectedProducts.reduce((acc, product) => acc + product.price, 0); ### What specific areas of your project would you like help with? I want feedback on state management
Community feedback
- @grgrnkooPosted 4 months ago
Good job! All nuances are perfectly worked out! Can not find anything that could be upgraded!
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord