diff --git a/lib/store.js b/lib/store.js index 1d9215f..7ceefa0 100644 --- a/lib/store.js +++ b/lib/store.js @@ -38,7 +38,7 @@ function remove(id) { // Returns the notes that match `term`. function matches(notes, term) { - return notes.filter((note) => note.text === term); + return notes.filter((note) => note.text.includes(term)); } function search(term) { diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..f81c5f1 --- /dev/null +++ b/notes.md @@ -0,0 +1,19 @@ +# Lesson 2 — commit message comparison + +## My quick version (what I'd dash off) +fix search + +## Claude's version (the actual commit message) +Fix search to match notes containing the term, not just exact matches + +`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 pass. + +## Comparison +The quick version ("fix search") says nothing about what was wrong or why the +change is correct. The fuller message explains the actual bug (exact-equality +vs. substring), names the function, and ties the fix to the tests — so a future +reader understands the *why*, not just that something changed.