Recap Challenge
Part of the Object Oriented Programming section of Coddy's JavaScript journey — lesson 38 of 56.
Challenge
You're given a Shape class and two child classes. Complete them using polymorphism concepts.
- In
Circleclass: Overridedescribe()to return:"This is a circle with radius [radius]" - In
Squareclass: Overridedescribe()to return:"This is a square with side [side]"
Try it yourself
import { Shape } from './shapes.js';
import { Circle } from './shapes.js';
import { Square } from './shapes.js';
// Test code - don't modify
const circle = new Circle(5);
const square = new Square(10);
console.log(circle.describe()); // Expected: "This is a circle with radius 5"
console.log(square.describe()); // Expected: "This is a square with side 10"All lessons in Object Oriented Programming
1Objects & The this Keyword
Quick Review: ObjectsAdding Methods to ObjectsUnderstanding the this KeywordConstructor FunctionsThe new KeywordRecap Challenge7 Inheritance & The extends Key
InheritanceThe "is-a" RelationshipThe extends KeywordThe super() MethodInheriting Properties&MethodsRecap Challenge2Organizing Code
What are Modules?Exporting with exportImporting with importDefault vs. Named Exports8Organizing OOP Code
Organize Classes into Modules11Project: A Shape Renderer
Setup: Shape Class & ExportCircle Class Inheritance9Static Methods & Properties
Class-Level vs. Instance-LevelStatic PropertiesStatic Utility MethodsRecap challenge