# Assessment wanted for OOJS 1 and 2

**URL:** <https://discourse.mozilla.org/t/assessment-wanted-for-oojs-1-and-2/97334>\
**Category:** Learn\
**Created:** [May 18, 2022, 5:40am UTC](https://discourse.mozilla.org/t/assessment-wanted-for-oojs-1-and-2/97334 "2022-05-18T05:40:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robmdnnyc](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@robmdnnyc](https://discourse.mozilla.org/u/robmdnnyc)\
**Post date:** [May 18, 2022, 5:40am UTC](https://discourse.mozilla.org/t/assessment-wanted-for-oojs-1-and-2/97334/1 "2022-05-18T05:40:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![justsomeone](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/justsomeone/32/67787_2.png) [@justsomeone](https://discourse.mozilla.org/u/justsomeone)\
**Post date:** [May 20, 2022, 1:10pm UTC](https://discourse.mozilla.org/t/assessment-wanted-for-oojs-1-and-2/97334/2 "2022-05-20T13:10:28Z")

</div>

Hello @robmdnnyc

you doing great well done

they used the prototype way for the same thing you did using class  
check this lesson to learn more about it

> **[Object prototypes - Learn web development | MDN](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Advanced_JavaScript_objects/Object_prototypes)**
>
> Prototypes are the mechanism by which JavaScript objects inherit features from one another. In this article, we explain what a prototype is, how prototype chains work, and how a prototype for an object can be set.

i know this task was for the class lesson but looks like they liked to use the other way

hope that help and have a nice day 🙂
