Javascript problem with classes and arrays

Hello everyone!
I’m solving this lesson:

I thought I was grasping it well until the creation of a class Book which cannot add any rating to it since ratings is undefined (although I set it equals to in the Media costructor).
What am I doing wrong?

Here’s the link to my code:

Neither a Media or a Book have ratings initialized…
Thanks for the help!

if we add a log statement in your constructor:

  costructor(title) {
    console.log('hello world');
    this._title= title;
    this._isCheckedOut = false;
    this._ratings = [];

we can see the constructor is never called. How could this be?

1 Like

found it… the word constructor was missing a letter and was costructor instead…
the method toggleCheckOutStatus() was working probably because _isCheckedOut is undefined and thus a falsy value…
I thought an error would rise if a keyword is mispelled
Thanks for the quick response!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.