Question: Question 2 : Create a Shape class with three properties: name, sides, and sideLength. Add a constructor to this class. The constructor takes arguments for
Question : Create a Shape class with three properties: name, sides, and sideLength. Add a constructor to this class. The constructor takes arguments for the name, sides, and sideLength properties, and initializes them. Add a new method calcPerimeter method to the class, which calculates its perimeter the length of the shape's outer edge and logs the result to the console. Create a new instance of the Shape class called square. Give it a name of square and a sideLength of Call your calcPerimeter method on the instance, to see whether it logs the calculation result to the browser's console as expected. Create a new instance of Shape called triangle, with a name of triangle and a sideLength of Call triangle.calcPerimeter to check that it works fine.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
