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 | ||||||||||||||
|
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started