# Assesment help wanted with OOJS 2

**URL:** <https://discourse.mozilla.org/t/assesment-help-wanted-with-oojs-2/120757>\
**Category:** Learn\
**Created:** [July 1, 2023, 5:20pm UTC](https://discourse.mozilla.org/t/assesment-help-wanted-with-oojs-2/120757 "2023-07-01T17:20:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![manishjoshicsj](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@manishjoshicsj](https://discourse.mozilla.org/u/manishjoshicsj)\
**Post date:** [July 1, 2023, 5:20pm UTC](https://discourse.mozilla.org/t/assesment-help-wanted-with-oojs-2/120757/1 "2023-07-01T17:20:27Z")

</div>

Link to the assessment: [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Test\_your\_skills:\_Object-oriented\_JavaScript](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Test_your_skills:_Object-oriented_JavaScript)

Link to my code: [https://codepen.io/redorteal/pen/OJamrBZ](https://codepen.io/redorteal/pen/OJamrBZ)

In the assessment, I am supposed to implement a Square class inheriting from the Shape class. I have to implement a method called `calcArea` that will calculate the area of a Square object.

The issue I’m facing:

I declare a property called `sideLength` in the Square class. I then call the super function with three arguments: `{name: 'square', sides: 4, sideLength}`.

I expect the superclass to define the `sideLength` property for the instance. But `this.sideLength` is `undefined` when I access it in the `calcArea` method. If I remove the `sideLength` declaration from the Square class, `sideLength` is defined, and everything works as expected.

**Why does the `sideLength` property remain undefined after calling the `super` function when it is declared in the subclass?**

Thanks

---

<div class="post-metadata">

**Author:** ![KBar](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@KBar](https://discourse.mozilla.org/u/KBar)\
**Post date:** [August 23, 2023, 10:38am UTC](https://discourse.mozilla.org/t/assesment-help-wanted-with-oojs-2/120757/2 "2023-08-23T10:38:51Z")

</div>

Because you’re not initializing it in the subclass. Subclass fields shadow those inherited from the prototype. You need to initialize `sideLength` in the subclass constructor.
