Hello, i have this error and i don’t understand why . Some help plz !!
/home/ccuser/workspace/learn-javascript-classes-build-a-library/app.js:3
this.title = title;
^
TypeError: Cannot set property title of Media which has only a getter
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 (reply) {
return this.isCheckedOut = reply;
}
getAverageRating() {
const myReducer = (acc, cur) => acc + cur;
let average = this.ratings.reduce(myReducer);
return average / this.ratings.length;
}
toggleCheckOutStatus() {
this.isCheckedOut = !this.isCheckedOut;
}
addRating(value) {
this.ratings.push(value);
}
}
class Book extends Media {
constructor(title, pages, author){
super(title);
this.pages = pages;
this.author = author;
}
get author(){
return this.author;
}
get pages(){
return this.pages;
}
}
class Cd extends Media {
constructor(title, artist, songs){
super(title);
this.artist = artist ;
this.songs = songs ;
}
get artist (){
return this.artist ;
}
get songs (){
return this.songs ;
}
}
class Movie extends Media {
constructor(title, director, runTime){
super(title);
this.director = director;
this.runTime = runTime;
}
get director (){
return this.director;
}
get runTime(){
return this.runTime;
}
}
const bookOne = new Book ('A Short History of Nearly Everything', 544, 'Bill Bryson');