Skip to content

Fix search to match notes containing the term#9

Open
VikLchv wants to merge 1 commit into
mate-academy:mainfrom
VikLchv:fix-search
Open

Fix search to match notes containing the term#9
VikLchv wants to merge 1 commit into
mate-academy:mainfrom
VikLchv:fix-search

Conversation

@VikLchv

@VikLchv VikLchv commented Jun 20, 2026

Copy link
Copy Markdown

Unit 4 Lesson 2 — fix the shipped bug, then commit it cleanly.

The bug

search should return every note that contains the term, but matches() in lib/store.js compared with ===, so "milk" only matched a note whose text was exactly "milk" — missing "buy milk" and "milk the almonds".

The fix

One line: switched the predicate to String.includes, which is what the two failing tests expect.

Tests

Started red (2 of 3 failing, on purpose). After the fix, all 3 pass (npm test).

notes.md records the quick "fix search" message I'd have dashed off vs. the fuller message, as the lesson asks.

🤖 Generated with Claude Code

search is meant to return every note that contains the term, but matches() in
lib/store.js compared with ===, so "milk" only matched a note whose text was
exactly "milk" — missing "buy milk" and "milk the almonds". Switched the
predicate to String.includes, which is what the two failing tests expect.
All three tests now pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <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