Question: create a new class called rectangle Rectangletests: // const myRectangle = new Rectangle(3, 5); // console.log(myRectangle.width === 3); // console.log(myRectangle.height === 5); // console.log(myRectangle.perimeter() ===

create a new class called rectangle

Rectangletests:

// const myRectangle = new Rectangle(3, 5);

// console.log(myRectangle.width === 3);

// console.log(myRectangle.height === 5);

// console.log(myRectangle.perimeter() === 16);

// console.log(myRectangle.area() === 15);

create a new class called Square

// cheat sheet: a square is just a rectangle where the width and the height are the same! the tricky part here is building the right constructor. once that is done, the Rectangle class will do all the work. in other words, you should not have to define a new perimeter and area for the square.

// Write your Square class here

Squaretests

// const mySquare = new Square(2);

// console.log(mySquare instanceof Rectangle === true);

// console.log(mySquare.width === 2);

// console.log(mySquare.height === 2);

// console.log(mySquare.perimeter() === 8);

// console.log(mySquare.area() === 4);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!