← Back to challenges

Find the Bug: Returning the Container

JavaScriptHardbugscontrol_flowconditionslogic

Instructions

The packaging system is running wild! The candy is lying loose all over in the warehouse, the cereal is missing, and bread is stuffed in a bottle. What is going on here? The candy should be in plastic and the bread should be in a bag.

The packaging machine is running the getContainer() function to retrieve the container of a product. But something is not right...

Examples

getContainer("Bread") ➞ "bag"

getContainer("Beer") ➞ "bottle"

getContainer("Candy") ➞ "plastic"

getContainer("Cheese") ➞ null

Notes

Think about what the object's packaging should be.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Destructuring Assignment