Your 15-minute checkpoint
Close the earlier examples. Spend two minutes writing the inputs, expected outputs, and steps in plain language. Use about eight minutes to build and test, then five to explain your choices and try the variation. Taking longer is normal: these are study budgets, not speed tests.
Use records, arrays, and deliberate copying. This problem deliberately changes the setting so you practise choosing the tools yourself.
A small warm-up
Before the main task, predict this familiar idea from today’s work. If it is unclear, revisit the relevant teaching lesson first.
Check the foundation
Say why each line appears, not just what it prints.
const item = { quantity: 2 };
const copy = { ...item, quantity: 3 };
console.log(item.quantity);
console.log(copy.quantity);Check your prediction
2
3Use this only as a warm-up. The main task needs you to combine several decisions.
Acceptance cases before you code
Write a small test plan before implementing packing data and copies. These cases extend the brief; they are not a second worked solution. Predict the expected behavior independently, then test through the public function. A good ordinary example and a good boundary example should catch different possible mistakes.
| Case to try | What your result should demonstrate |
|---|---|
| Empty packing list | Zero pieces and no unpacked names |
| Packed item with quantity greater than one | Count pieces, not just records |
| Revised first record | Original packed flag and unrelated records remain unchanged |
After the core task passes, deliberately break one rule and identify the case that notices it. Restore the implementation and explain the failure in terms of the contract, not the number of assertions. If a case requires a concept you have not recalled, revisit the relevant lesson before opening the solution.
An equipment inventory
Each item has name, quantity, and packed. Count all pieces and list unpacked names. Then make a revised copy of the first record marked packed, leaving the original unchanged.
const items = [
{ name: "Notebook", quantity: 2, packed: false },
{ name: "Pen", quantity: 3, packed: true }
];Hint 1: the idea
Use a number for the total and an array for the names.
Hint 2: a first step
Loop through items; add quantity and push name only when packed is false.
Show one solution
const items = [
{ name: "Notebook", quantity: 2, packed: false },
{ name: "Pen", quantity: 3, packed: true }
];
let pieces = 0;
const unpacked = [];
for (const item of items) {
pieces += item.quantity;
if (!item.packed) {
unpacked.push(item.name);
}
}
const revised = { ...items[0], packed: true };
console.log(pieces);
console.log(unpacked.join(", "));
console.log(items[0].packed);
console.log(revised.packed);5
Notebook
false
trueTry two unpacked items. Then test the counting and name-listing part with no items; it should count zero. Skip making a copy of the first item when the list is empty, because there is no first record. Decide what text an empty unpacked list should display instead of a blank line.
Change the requirements
Try two unpacked items. Then test the counting and name-listing part with no items; it should count zero. Skip making a copy of the first item when the list is empty, because there is no first record. Decide what text an empty unpacked list should display instead of a blank line.
Decide what to revisit
- Can you explain each variable and the reason for each condition?
- Did you check an empty, boundary, or changed input rather than only the supplied one?
- Can you rebuild the essential part after closing the solution?
If you needed a hint, record the specific missing idea and revisit that lesson. Marking a page done records progress; it does not replace practice. Begin tomorrow by rebuilding one small part from memory.
Completion is saved in this browser only. It does not measure mastery.