Course · Section 14: Object-Oriented Programming (OOP) With JavaScript · Lecture 226: ES6 Classes
Define a base `Shape` class with `Square` and `Rect` subclasses overriding `area()`. Implement `shapeAreas(shapes)` mapping each shape descriptor to its area. A square has `{ type: 'square', side }`; a rectangle has `{ type: 'rect', w, h }`.
+ 1 hidden test run on Submit.
Subclasses override area() and the mapper picks the right class per descriptor, demonstrating polymorphism.
Run your code to see results.