Javascript: Square generator

JS: Introduction to Object Oriented Programming (OOP)
Last update: 14 Jan 23:20
0
Students

Square.js

Implement and export the Square class as default. The only property of a square is its side. Implement the getcode() method that returns the side value.

Example

const square = new Square(10);
square.getSide(); // 10

SquaresGenerator.js

Implement the SquaresGenerator class with a static generate() method that takes two parameters: the side and the number of square instances (5 by default) to be created. The function should return an array of squares. Export this class as default.

Example

const squares = SquaresGenerator.generate(3, 2);
// [new Square(3), new Square(3)]

For full access to the challenge you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
1000
exercises
2000+
hours of theory
3200
tests