Ask a learner to choose unfinished tasks that take at least 25 minutes, then return only their IDs. Four objects are enough to expose two common mistakes: dropping the task at exactly 25 minutes and forgetting to return a value from a callback.
This 25-minute online JavaScript lesson gives students a small input they can inspect by hand before running the code. Allow five minutes to predict the result, five to trace the condition, five to run the selection and mapping, five to repair a callback, and five to test a changed input. Learners need object properties, Boolean conditions, arrays, and basic function calls.
Predict the selected tasks before running code
Use this complete example in a JavaScript editor or a file run with Node.js. The task records are invented for the lesson. Every record has a string ID, a numeric duration, and a Boolean completion flag.
const tasks = [
{ id: "read", minutes: 20, done: false },
{ id: "code", minutes: 25, done: false },
{ id: "review", minutes: 30, done: true },
{ id: "plan", minutes: 40, done: false },
];
const selectedTasks = tasks.filter(
(task) => task.minutes >= 25 && task.done === false
);
const selectedIds = selectedTasks.map((task) => task.id);
console.log(JSON.stringify(selectedIds));
Before running it, ask each learner to write down the IDs they expect and explain the decision for every object. The result should be:
["code","plan"]
The reading task is too short. The coding task meets the duration boundary and is unfinished. The review task has enough minutes but is already done. The planning task meets both conditions.

Trace the callback on one object at a time
Ask the driver to substitute the coding task’s values into the condition. The duration comparison is 25 >= 25, which is true. The completion comparison is false === false, which is also true. The && expression is true, so the task is included.
Next, trace the review task. Its duration comparison is true, while true === false is false. Both conditions must hold for this selection rule.
Here, filter() returns an array containing the objects whose callback result passes the test. The resulting array is a shallow copy, so its objects share references with the input. For this dataset, selectedTasks[0] === tasks[1] evaluates to true. The example only reads those objects. MDN filter reference
Ask the learner what map() receives next. It receives the two selected task objects. Its callback returns each object’s ID, producing an array of strings. Pause before combining the calls into a chain so the class can inspect each intermediate result. MDN map reference
Reproduce an empty result caused by a missing return
Keep the original four task records and replace just the selection statement with this deliberately faulty version.
const selectedTasks = tasks.filter((task) => {
task.minutes >= 25 && task.done === false;
});
Keep the mapping and output statements below it. The printed result is now []. Ask a learner to point to the value the callback gives back to filter().
The comparison still runs, but the block body returns undefined because it has no return statement. That result causes each task to be excluded. Repair the callback as follows.
const selectedTasks = tasks.filter((task) => {
return task.minutes >= 25 && task.done === false;
});
Run the repaired version and expect ["code","plan"] again. The expression-body arrow in the original complete example also returns its expression. The braces in the faulty version make it a block body that needs an explicit return for this result. MDN arrow function reference
An empty array can also be a correct result when no tasks meet a rule. Ask students to compare the callback and the input before deciding what to fix.

Test the boundary with one change per run
Return to the complete working example before each variation. Ask the learner to predict the new output, change one value or operator, run it, and explain any difference.
- Change the coding task from 25 minutes to 24. The result becomes
["plan"]. - Change the reading task from 20 minutes to 25. The result becomes
["read","code","plan"]. - Change the review task’s completion flag to
false. The result becomes["code","review","plan"]. - Change the comparison from
>= 25to> 25. The result becomes["plan"], showing why the original “at least 25” requirement needs the inclusive comparison.
Have the observer check that the output contains the expected IDs in their input order. Then swap roles and rerun a different variation. Online pair programming guide
Finish with a short explanation and a fresh input
Ask each learner to add one invented task at exactly 25 minutes with done: true. It should be excluded. Then change only its flag to false and explain why its ID appears. Their explanation should name the two conditions and the value returned by each callback.
For the last check, ask what shape the data has after filtering and after mapping. Students should identify selected task objects first, then their string IDs.
If your cohort uses a browser editor, test its editor and preview hostnames before the session. In Focus Room, allow the required hosts in the participating browser during the active extension session. Review code execution and learner explanations in your normal teaching tools. Focus Room website-rule setup

