Menu
Coddy logo textTech

Recap Challenge

Part of the Object Oriented Programming section of Coddy's JavaScript journey — lesson 38 of 56.

challenge icon

Challenge

You're given a Shape class and two child classes. Complete them using polymorphism concepts.

  1. In Circle class: Override describe() to return: "This is a circle with radius [radius]"
  2. In Square class: Override describe() 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