------Assessment wanted for OOJS 2 skill test

I can’t figure out how to get the perimeter of a triangle. I’ve tried

let triangle = new Shape('triangle', 3, 10);

https://codepen.io/thinnling-the-scripter/pen/NWGQMzE

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Test_your_skills:_Object-oriented_JavaScript

Hi there @Green_Marble, and welcome to the community. Thanks for sending in your code!

So the formula you have for the calcArea() is actually correct for calcPerimeter() — the length of each side multiplied by the number of sides.

So if you change the calcPerimeter() definition to

calcPerimeter() {
    console.log(`${this.sides * this.sideLength}`);
 }

You can then call the method using this:

let triangle = new Shape('triangle', 3, 10);
triangle.calcPerimeter();

As for the triangle’s calcArea() method, I didn’t include this in any of the questions. If we assume the triangle is an equalateral triangle (because the sides are all the same length), we can then search for the formula:

Area = (a2√3)/4

Where a is the sideLength.

Try implementing this in your JS, and see where you get.