Skip to content

Add count command to print how many notes you have - #297

Open
Lemonch1ks wants to merge 1 commit into
mate-academy:mainfrom
Lemonch1k-learning:feature/count-command
Open

Lemonch1ks wants to merge 1 commit into
mate-academy:mainfrom
Lemonch1k-learning:feature/count-command

Conversation

@Lemonch1ks

Copy link
Copy Markdown

What changed

Adds a count command to the notes CLI:

$ node notes.js count
You have 3 notes.
  • notes.js — new count case; count added to the help line.
  • lib/format.js (new) — countMessage(n) builds the text: plural for many, You have 1 note. for one, You have no notes. for zero.
  • tests/format.test.js (new) — 3 tests covering 0, 1 and many.
  • README.md — documents the new command.

Why

Lesson 3 task: a small, self-contained change to practise branching and pull requests. Quickly seeing how many notes you have is handy without listing them all.

How it was checked

  • npm test — 6/6 pass (3 existing + 3 new).
  • Manually: empty store → You have no notes., after adding two notes → You have 2 notes.

For the reviewer

  • The message formatting lives in its own lib/format.js so it can be unit-tested without reading/writing notes.json (existing tests follow the same pure-function approach). Happy to fold it into store.js if preferred.
  • The zero case prints You have no notes. rather than You have 0 notes. — a wording choice worth a quick look.

🤖 Generated with Claude Code

`node notes.js count` prints e.g. "You have 3 notes." (singular for one
note, "You have no notes." when empty). Message formatting lives in
lib/format.js so it can be unit-tested without touching notes.json.

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