I am working through the build a Library Excercise in the Intro to JS course. I’m attempting to do this freehand without following the guidance as suggested for a bit of a challenge.
I am just getting started and doing a bit of checking on my parent class:
My code:
//parent class
class Media {
//parent class constructor
constructor(title) {
this._title = title;
this._ratings = [2,4];
this._isCheckedOut = false;
this._averageRating = 0
}
//getters
get title() {return this._title}
get ratings() {return this._ratings;}
get isCheckedOut() {return this._isCheckedOut}
getAverageRating(){
this._averageRating = this._ratings.reduce/this._ratings.length
}
}
const bonJovi = new Media(‘Livin’ on a prayer’)
bonJovi.getAverageRating()
console.log(bonJovi._averageRating)
the output i get to the console is NaN.
I dont see anywhere that would output anything that isnt a number.
can anyone explain where im going wrong?