Your question is Function Reading and Testing. Take a moment with it on the right.
Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).
While reviewing an older part of Asana's task-list module, you find this helper with no tests and a name that doesn't say what it does:
function doStuff(tasks: Task[], targetIds: string[]): Task[] {
const result: Task[] = [];
for (const id of targetIds) {
for (const task of tasks) {
if (task.id === id && !result.includes(task)) {
result.push(task);
}
}
}
return result;
}
Look at this existing function: tell me what it does, rename it to something practical, analyze its time complexity, and walk me through the test cases you would write for it before touching the implementation.