Hello. This is my code:
OOJS 1:
class Shape {
name;
sides;
sideLength;
constructor(name, sides, sideLength) {
this.name = name;
this.sides = sides;
this.sideLength = sideLength;
}
calcPerimeter() {
console.log(this.sideLength*this.sides);
}
}
let square = new Shape ("squareee", 4, 5);
let triangle = new Shape ("trianglee", 3, 3);
OOJS 2:
class Square extends Shape {
constructor(sideLength){
super("squarebb", 4, sideLength);
}
calcArea() {
console.log(this.name+this.sideLength*this.sideLength);
}
}
let square2 = new Square (5);
In oojs1, I saw other users’ solutions that read using:
**Shape.prototype.**calcPerimeter = function() {
return this.sides * this.sideLength
}
… instead of just calcPerimeter(). Why is that?
ps: it’s a bit dificult to keep the indentation used in vs code when pasting it here with no tabs and such.