Got to ‘build a library’ project in Javascript Syntax part 3, checked a class I made and the get function returns undefined on all properties, I’ve looked back to previous classes and cannot see the difference between the class example and my code (bar the naming conventions), could someone have a look to see if I’ve declared something wrong in the class:
class Media {
constrcutor(title) {
this._title = title;
this._isCheckedOut = false;
this._ratings = ;
}
get title() {
return this._title;
}
get isCheckedOut() {
return this._isCheckedOut;
}
get ratings() {
return this._ratings;
}
getAverageRating() {
if (this._rating) {
return this._rating.reduce((ratingSum, ratings) => ratingSum + ratings)/this._rating.length;
}
}
toggleCheckOutStatus() {
this._isCheckedOut = !this._isCheckedOut;
}
addRating(rating) {
this._rating.push(rating);
}
}
const poop = new Media(‘A Short History of poop’);
console.log(poop.title, poop.isCheckedOut, poop.ratings);
console returns: undefined undefined undefined