Build a Library Project (got stuck)

Ladies and gentlemen,
I got stuck on this project where I get an error that doesn’t allow me to move forward. I’d really appreciate if someone could explain to me what’s going on.

Please post a link to the CC landing page of this project. It will help immensely going forward.

1 Like


Just as a sidebar, I searched the community for posts containing the words, ‘post a link’ and after minutes of scrolling finally came upon,

There are more results. Please narrow your search criteria.

I’m going to do a deep dive into the results that did appear and am betting that the majority will be asking for a link to the exercise related to the question.

Why it is not intuitive to the user that this would be important in framing any usable answer is completely beyond me.

There are well over 400 records in the results and it does not bear any further examination. This is a common request. Users might learn from this small detail as evidenced even in the preliminary outcome of this study.

If one just wants to make it about one’s self, and their github code, then I guess we’re stuck with it.

People want us to believe there are diamonds when they know there are but seashells and sand and gravel. The real treasure is in the collective reasoning that cannot be put asunder by paroxysm.

First error I found was in the getAverageRatings function. On line 27 defining lengthOfRatings you didn’t use a this before referring to _ratings. I’ve added it in bold below.
getAverageRating() {
let ratingsSum = this.ratings.reduce(
(currentSum, rating) => currentSum + rating,
const lengthOfRatings = this._ratings.length;
return (this._ratings = ratingsSum / lengthOfRatings);

Next on line 72, you are calling your getter as if it was a function. Getters aren’t functions are you don’t need parenthesis. So instead of historyOfEverything.ratings() you just use historyOfEverything.ratings
It tripped me up heads on this project too I remember.
Your code still doesn’t work after that but at least it’s error free :slight_smile:
Good luck!

1 Like

Oh man, thank you very much. Indeed, your observations solved part of the problems. Now I need to understand why the code is returning “Not a Number”.

1 Like

And we’re still waiting for a link to the exercise for fuller context. For my own part, I won’t look at your code until after I’ve read the narrative and instructions for the project (and seen my old code).

Sorry, this is the link.

1 Like

My code includes a Catalog class, so is different from yours. I did find this one snippet at line 30 that raises an eyebrow:

  addRating() {

The parameter is missing.

Nothing else looks out of place, but it doesn’t mean everything is perfect. Fix the parts pointed out so far and see if any errors are raised.

1 Like

That was it, thank you very much. Working as a charm.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.