Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 5, 2021 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/2df021c7f72c18be256ace95a611c37d to your computer and use it in GitHub Desktop.
Save codecademydev/2df021c7f72c18be256ace95a611c37d to your computer and use it in GitHub Desktop.
Codecademy export
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