diff --git a/curriculum/challenges/english/blocks/lab-smart-pantry-restocker/69a5f35669099ed52f8563b1.md b/curriculum/challenges/english/blocks/lab-smart-pantry-restocker/69a5f35669099ed52f8563b1.md index 5e528ad3dd0..1428b70f065 100644 --- a/curriculum/challenges/english/blocks/lab-smart-pantry-restocker/69a5f35669099ed52f8563b1.md +++ b/curriculum/challenges/english/blocks/lab-smart-pantry-restocker/69a5f35669099ed52f8563b1.md @@ -31,7 +31,7 @@ The `rawData` array contains pipe-separated strings with the format `sku|name|qt - Otherwise, if the shipment item's `sku` already exists in the pantry, the action `type` should be `"restock"`. - Otherwise (the shipment item's `sku` does not exist in the pantry), the action `type` should be `"donate"`. -3. You should implement a `groupByZone(actions)` function that groups the actions into storage zones based on each item’s `zone` property. +3. You should implement a `groupByZone(actions)` function that groups the actions into storage zones based on each item's `zone` property. The function should return an object where each key is a zone name and the value is an array of actions belonging to that zone. For example, if actions contain items with zones `"fridge"` and `"pantry"`, the result should be `{ fridge: [...], pantry: [...] }`. 4. You should implement a `clonePantry(pantry)` function that returns a deep copy of the pantry so planning changes do not affect the original list. A deep copy means creating a new array with new objects, so modifying the copy does not change the original pantry. @@ -181,6 +181,23 @@ assert.isArray(result.fridge); assert.isArray(result.pantry); ``` +Your `groupByZone` function should correctly group actions with the right content and count. + +``` js +const actions = [ + { type: "restock", item: { sku: "A1", zone: "fridge" } }, + { type: "donate", item: { sku: "B1", zone: "fridge" } }, + { type: "discard", item: { sku: "C1", zone: "pantry" } }, +]; + +const result = groupByZone(actions); + +assert.lengthOf(result.fridge, 2); +assert.lengthOf(result.pantry, 1); +assert.strictEqual(result.fridge[0].item.sku, "A1"); +assert.strictEqual(result.pantry[0].type, "discard"); +``` + You should define a function named `clonePantry` that accepts one parameter called `pantry`. ``` js