Shopping CartLoading saved progress…

Shopping Cart

A cart has one editable collection and several values derived from it. Build the React version with immutable state updates, quantity controls, removal, live line totals, and a live grand total.

Signature

Implement the App component in App.tsx. It receives no props and renders the provided three-item cart.

Examples

  • Keyboard $49.00 x1, Mouse $25.50 x2, Monitor $199.99 x1 gives lines $49.00, $51.00, $199.99 and a grand total of $299.99.
  • Press + on Mouse and its qty becomes 3, its line becomes $76.50, and the grand total becomes $325.49.
  • The Keyboard decrement starts disabled because its quantity is 1; quantity never falls below 1.
  • Remove all three rows and you get Your cart is empty with a $0.00 total.

Notes

  • State and derivation. Put initialItems in useState; derive line totals and the grand total during render.
  • Immutable actions. Use map for quantity changes and filter for removal. Clamp decrement with Math.max(1, qty - 1).
  • Accessible controls. Keep the item-specific button labels, disable decrement at the floor, announce each quantity with its <output>, announce the total atomically, and give the empty message role="status".
  • Starting shell. The starter supplies the data, resting markup, accessible labels, and persistent CSS. Add the state, handlers, event wiring, and empty-state branch.
WE’RE LISTENING

Help make UIReady better

Found a bug or have an idea? Tell us about it.

Up to 3 files · 5 MiB each · JPG, PNG, WebP, MP4, WebM, MP3, M4A or WAV