Assessment wanted for OOJS 1 skill test. Task-2.

Task-2.

by EiNzp

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <title>OOJS: Task 2</title>
    <link rel="stylesheet" href="styles/style.css">
  </head>

  <body>

    <section class="preview">



    </section>

  </body>
  <script src="scripts/script.js"></script>

</html>

CSS

p {
    color: purple;
    margin: 0.5em 0;
}

* {
    box-sizing: border-box;
}

JavaScript

class Shape {
    name;
    sides;
    sideLength;

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

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

class Square extends Shape {    
    constructor (sideLength){
        super(Shape)
        this.name = 'square';
        this.sides = 4;
        this.sideLength = sideLength;    
    }
            
    calcArea(){
        console.log(Math.pow(this.sideLength, 2));
    }
}

const square = new Square(5);
square.calcPerimeter();
square.calcArea();