Follow the unassigned filter
A fictional teaching board must show sessions that have no facilitator. Read the implementation before changing it.
javascript
function unassigned(sessions) {
return sessions.filter(session => session.facilitator === "");
}
const sessions = [
{ id: "T1", title: "Journal club", facilitator: "Jo" },
{ id: "T2", title: "Skills lab", facilitator: "" }
];
console.log(unassigned(sessions));- 1
Predict
Which records will the function return? Trace the predicate for each input.
- 2
Explain
Why does filter fit this job? Does it change the original array?
- 3
Challenge
A new record omits facilitator entirely. What happens now, and where should you define the intended rule?
Your explanation
Use your own words. Include the evidence you would look for and the assumptions you are making.
Use synthetic information only. Notes are saved when you choose Save practice.
Sign in before writing to save your explanation and self-assessment to your account.
Sign in