Skip to content

Conversation

@bit-sercererx
Copy link

No description provided.

//TODO: ADD YOUR CODE HERE
return reviewers.find((items) => {
items.some((value) => {
return value.books === reviewTitle;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the condition for getting the reviewer by the title is incorrect, you should do this instead:

return reviewers.find((items) => {
  items.some((value) => {
     return value.title === reviewTitle;
   } 
}

Which is basically using the reviewerHasReview function, so you can use that instead:

  return reviewers.find((reviewer) => reviewerHasReview(reviewTitle, reviewer));

and returns an array of the reviewer objects that contain the query in their name/description.
- Hint: uses string method .includes() and iteration method .filter()
****************************************************************/
function searchReviewers(query, reviewers) {
Copy link

@AlhassanAli01 AlhassanAli01 Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can not use return three times in the same function, the return should be only used once, unless it's inside an if statement or a swtich case.

This function could be easily done using the filter method:

 return reviewers.filter(
    (reviewer) =>
      reviewer.reviewerName.includes(query) ||
      reviewer.description.includes(query)
  );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants