Course · Section 14: Object-Oriented Programming (OOP) With JavaScript · Lecture 226: ES6 Classes
Model a shopping cart. Implement `ShoppingCart`: - `addItem(name, price, qty)` adds a line item. - `removeItem(name)` removes all lines with that name. - `total()` returns the sum of price times quantity. - `count()` returns the total quantity of items.
+ 1 hidden test run on Submit.
An array of line items with reduce-based aggregates models cart totals and counts cleanly.
Run your code to see results.