Hey guys I’m running my code for the Build a Library project in the intermediate Javascript course and get this reference error saying this is not defined in the Book class. I can’t seem to figure out the issue.
class Media {
constructor(title) {
this._title = title;
this._isCheckedOut = false;
this._ratings = [];
}
get title() {
return this._title;
}
get isCheckedOut() {
return this._isCheckedOut;
}
get ratings() {
return this._ratings;
}
set isCheckedOut(value) {
this._isCheckedOut = value;
}
toggleCheckOutStatus(isCheckedOut) {
this.isCheckedOut = !this.isCheckedOut;
}
getAverageRating() {
let ratingsSum = this.ratings.reduce(
(accumulator, rating) => accumulator + rating
);
return ratingsSum / this.ratings.length;
}
addRating(value) {
this.ratings.push(value);
}
}
class Book extends Media {
constructor(author, title, pages) {
this._author = author;
super(title);
this._pages = pages;
}
get author() {
return this._author;
}
get pages() {
return this._pages;
}
}