Assessment wanted for objct oriented js,Unable to get the output

class Shape {

name;
sides;
sideLength;
constructor(name,sides,sideLength){
this.name=name;
this.sides = sides;
this.sideLength = sideLength;

}
calcPerimeter() {
let perimeter = ${this.sides}*${this.sideLength};
console.log(perimeter);
}
const square = new Shape();
square.calcPerimeter(‘square’,4,5);

Can any one suggest me what went wrong?Thank you.

Hi @vaishnavi_A.N

Your constructor expects three parameters. You need to pass them when creating the shape with new: const square = new Shape('square', 4, 5);. calcPerimeter() doesn’t have any parameters but uses the previously saved values of the object. Therefore you can remove them from square.calcPerimeter().

On a general note: When posting code on this forum it would be helpful to use “code fences” (three backticks before and after your code) to properly format it:

```
Your code
```

Please tell me if you need more help :slightly_smiling_face:

Cheers,
Michael

1 Like