Skip to content

Fix search to match notes containing the term - #321

Open
Lemonch1ks wants to merge 1 commit into
mate-academy:mainfrom
Lemonch1k-learning:fix/search-substring-match
Open

Lemonch1ks wants to merge 1 commit into
mate-academy:mainfrom
Lemonch1k-learning:fix/search-substring-match

Conversation

@Lemonch1ks

Copy link
Copy Markdown

The matches helper compared each note's text to the search term with strict equality, so notes search milk only returned a note whose whole text was exactly "milk". The search command is meant to list every note that contains the term, so "buy milk" and "milk the almonds" were missed.

Use String.prototype.includes for a substring match instead. This makes the two failing search tests pass; all three tests are green.

The `matches` helper compared each note's text to the search term with
strict equality, so `notes search milk` only returned a note whose whole
text was exactly "milk". The search command is meant to list every note
that contains the term, so "buy milk" and "milk the almonds" were missed.

Use `String.prototype.includes` for a substring match instead. This
makes the two failing search tests pass; all three tests are green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant