-
-
Save codecademydev/2df021c7f72c18be256ace95a611c37d to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(newisCheckedOut) { | |
this._isCheckedOut = newisCheckedOut; | |
} | |
toggleCheckOutStatus() { | |
this._isCheckedOut = !this._isCheckedOut; | |
} | |
getAverageRating() { | |
return this.ratings.reduce((currentSum, rating) => currentSum + rating) / this.ratings.length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment