Skip to content
Advertisement

Helper function keeps giving syntaxError about missing syntax after argument?

I am trying to implement a helper function into my function that is trying to solve and sort an array of books into the top 5 most popular books. For some reason I keep receiving a syntaxError stating that I’m missing syntax after my argument. Ive gone through my code and everything looks right but maybe I am overlooking something? Any help would be appreciated thanks.

This is the prompt I’m given:

The getMostCommonGenres() function in public/src/home.js has a single parameter:

  • An array of books.

It returns an array containing five objects or fewer that represents the most common occurring genres, ordered from most common to least.

Each object in the returned array has two keys:

  • The name key which represents the name of the genre.
  • The count key which represents the number of times the genre occurs.

If more than five genres are present, only the top five should be returned.

Here is a portion of the data used:

JavaScript

Here is what I’ve tried:

JavaScript

I am trying to solve this prompt with a helper function, I know it doesn’t need the helper function but that’s what I am having to add, once again any help would be appreciated. Thanks!

Advertisement

Answer

It’s just a small problem with your brackets:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement