Build a Library - Cannot read property 'push' of undefined

I’ve gone through other forum posts on this topic and I’ve checked my code back and forth. Still can’t see the problem.

Here is my code:

Class Media {
constructor(title) {
const _title = title;
const _isCheckedOut = false;
const _ratings = ;
}
get title() {
return this._title;
}
get isCheckedOut() {
return this._isCheckedOut;
}
get ratings() {
return this._ratings;
}
set isCheckedOut(status) {
this._isCheckedOut = status;
}
toggleCheckOutStatus() {
this.isCheckedOut = !this.isCheckedOut;
}
addRating(value) {
this.ratings.push(value);
}
getAverageRating() {
let reducer = this.ratings.reduce((accumulator, currentValue) => accumulator + currentValue);
return reducer / this.ratings.length;
}
}

class Book extends Media {
constructor(author, title, pages) {
super(title)
this._author = author;
this._pages = pages;
}
get author() {
return this._author;
}
get pages() {
return this._pages;
}
}

class Movie extends Media {
constructor(director, title, runTime) {
super(title)
this._director = director;
this._runTime = runTime;
}
get director() {
return this._director;
}

get runTime() {
return this._runTime;
}

}

const historyOfEverything = new Book(‘Bill Bryson’, ‘A Short History of Nearly Everything’, 544);

historyOfEverything.toggleCheckOutStatus();

console.log(historyOfEverything.isCheckedOut);

historyOfEverything.addRating(4);
historyOfEverything.addRating(5);
historyOfEverything.addRating(5);

Hello, and welcome to the forums.

You only have one .push() call in your code:

addRating(value) {
  this.ratings.push(value);
}

Is the array you’re storing the ratings in called ratings?

Another hint

Look at how you’re returning the array in your getter for ratings.

I’ve tried changing it to _ratings, but it doesn’t solve the problem.

Compare the Media class constructor to the constructor you’re using for Book. In one you’re declaring locally scoped variables that go away after the constructor code runs, and in the other you’re attaching properties to the class that persist.

Also, this may just be the forum formatting combined with your browser’s auto-correct, but it shows Class for Media instead of class

If you’re still not able to solve it, repost your code with this option instead of Blockquote so it’s easier to read in the forums:
image