Skip to content

Conversation

@KJ-MU
Copy link

@KJ-MU KJ-MU commented Feb 16, 2024

No description provided.

**************************************************************/
function findFirstStringStartingWithLetter(letter, strings) {
//TODO: Add your code here
strings = strings.map((value, index, array) => {
Copy link

@AlhassanAli01 AlhassanAli01 Feb 22, 2024

Choose a reason for hiding this comment

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

You didn't have to loop over every string in the array to make them lower cased, instead you could've just done that inside the find method like so:
strings.find( (value)=> value.toLowerCase().startsWith(letter))

strings = strings.map((value, index, array) => {
return value.toLowerCase();
});
console.log(strings.filter((value) => value.startsWith(letter)));

Choose a reason for hiding this comment

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

You're supposed to find only one item using the find method, hence the name of the function findFirst...

function searchReviewers(query, reviewers) {
//TODO: ADD YOUR CODE HERE
query = query.toLowerCase();
reviewers.map((element) => {
Copy link

@AlhassanAli01 AlhassanAli01 Feb 22, 2024

Choose a reason for hiding this comment

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

You didn't have to loop over the array twice to make the reviewerName & description lower cased, you could've done so directly inside the filter method, since you have the value there and you can just attach .toLowerCase to each value there.
i.e:

if (
      value.reviewerName.toLowerCase().includes(query) &&
      value.description.toLowerCase().includes(query)
    ) {
      return value;
    }

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