Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Outline Watson and Rayners classic work on fear conditioning.

Answered: 1 week ago

Question

What are bounds and what do companies do with them?

Answered: 1 week ago