The function below returns every memo in the system, regardless of who is asking.
The bug: this is the real behavior of OWASP's NodeGoat (a deliberately-vulnerable Node.js app used for security training) — its memo-listing endpoint fetches all memos from the database and renders them, without ever filtering by the logged-in user. Any authenticated user can read every other user's private memos just by visiting the page.
Your task: fix solve(allMemos, currentUserId) so it returns only the memos that belong to currentUserId.
const memos = [
{ id: 1, userId: 'alice', text: 'Buy milk' },
{ id: 2, userId: 'bob', text: 'Call the bank' },
];
solve(memos, 'alice') // → [{ id: 1, userId: 'alice', text: 'Buy milk' }]Sample tests