Https://www.codecademy.com/paths/web-development/tracks/webdev-intermediate-javascript/modules/learn-javascript-classes/projects/build-a-library

LINK: https://www.codecademy.com/paths/web-development/tracks/webdev-intermediate-javascript/modules/learn-javascript-classes/projects/build-a-library

I made the project, but I cant get the result for the ratings.

this is the result:

true
[Function: getAverageRating]
true
[Function: getAverageRating]

this is the code: dont know why the forum do not let me paste the full code…

`class Media {
constructor(title) {
this._title = title;
this._isCheckedOut = false;
this._ratings = ;
}

get title() {
return this._title;
}

const speed = new Movie(‘Jan de Bont’, ‘Speed’, 116)
speed.toggleCheckOutStatus()
console.log(speed.isCheckedOut)
speed.addRating(1)
speed.addRating(1)
speed.addRating(5)
console.log(speed.getAverageRating);`

here is just the code of the 'ratings topic, bc the forum do not let me post the full code:

getAverageRating() {
  let ratingsSum = this.ratings.reduce((currentSum, rating) => currentSum + rating, 0);
  return ratingsSum / this.ratings.length;
}

addRating(value) {
  this.ratings.push(value);
}

Hello @jhonathanc. Make sure to include parentheses after a function call, even if it takes no arguments. You might want to specifically look at this line:

In JS, when you log a function without parenthesis, it prints the type(Function) and the name of the function, like so:

[Function: functionName]

You might want to look at this line as well-although I’m not entirely sure if isCheckedOut is a function:

I hope this helps!

1 Like