Capacities: connect scattered notes through a project
Capacities is a personal note-taking and knowledge management tool. It organizes meetings, people and projects as connected objects, helping you return from a topic to the records related to it.
Break down the problem and try your own design and implementation first. Then explore the reasoning to check states, edge cases, trade-offs, and ways to test your approach. The guide offers a reasoning path, not a complete implementation.
01
CODE EXERCISE
Find the notes linked to a project
Write a function that finds notes belonging to a specified project. Each note has a string id and a list of strings named projectIds. All input fields are present.
- Input and output: Accept a list of notes and a project ID. Return the matching note IDs. For example, given
[{id: "N1", projectIds: ["P1"]}, {id: "N2", projectIds: ["P2", "P1"]}, {id: "N3", projectIds: []}]and project ID"P1", return["N1", "N2"]. - Rules: Match project IDs by exact string equality and keep the input order of the notes. Note IDs are unique. Return
[]if nothing matches or the input list is empty. - Deliver: Write the function and check the example, project ID
"P3", and an empty note list. Use local data.
Explore the reasoning
- For each note, check whether its
projectIdscontains the target project ID. - Keep the IDs of matching notes in their original order.
- Confirm that the example gives N1 and N2, then check the no-match and empty-list results.