This folder contains JavaScript exercises focused on working with objects — including accessing properties, comparing object structures, and applying rule-based matching. These labs emphasize how objects store related data and how key/value relationships are evaluated programmatically.
More object-focused practice labs will be added here as learning progresses.
This lab filters an array of objects and returns only those that contain all key/value pairs specified in a source object. It demonstrates how structured data can be evaluated using dynamic property comparison.
whatIsInAName(
[{ first: "Romeo", last: "Montague" }, { first: "Tybalt", last: "Capulet" }],
{ last: "Capulet" }
)
→ [{ first: "Tybalt", last: "Capulet" }]
whatIsInAName(
[{ apple: 1, bat: 2 }, { bat: 2 }],
{ apple: 1, bat: 2 }
)
→ [{ apple: 1, bat: 2 }]
Object.keys() to extract property namesThis lab introduces deeper interaction with structured data by moving beyond simple values to key/value relationships. Instead of transforming array elements, the function evaluates whether objects meet a set of property requirements. This mirrors real-world tasks such as data filtering, query matching, and record validation.
This lab implements a poll system that tracks votes for different options using structured collections. It ensures that each voter can only vote once per option and maintains a count of votes for each choice.
addOption("Turkey")
→ Option "Turkey" added to the poll.
vote("Turkey", 1)
→ Voter 1 voted for "Turkey".
vote("Turkey", 1)
→ Voter 1 has already voted for "Turkey".
displayResults()
→
Poll Results:
Turkey: 2 votes
Morocco: 1 votes
Japan: 0 votes
Map to associate options with votersSet to enforce unique valuesThis lab demonstrates how combining Map and Set can enforce real-world constraints such as one vote per user. Instead of relying on conditional logic alone, the data structures themselves help maintain integrity. This approach reflects practical patterns used in applications that require uniqueness, tracking, and controlled state updates.
This lab models a plant inventory system using object-based records and keyed collections. It tracks plant varieties and their inventory counts by size, allowing updates such as selling items, removing plants, and displaying catalog data.
sellPlants(ballerina, "small", 5)
→ "Catalog successfully updated."
sellPlants(willowVale, "large", 1)
→ "Not enough large size pots for Lavandula stoechas 'Willow Vale'. Only 0 left."
removePlant(royalCrown)
→ true
Map for key-based data storageforEachSet to extract unique valuesThis lab expands object usage into real-world data modeling by combining objects with specialized collection types like Map and Set. Instead of working with isolated objects, the system manages relationships between data entities and their associated state. This mirrors practical scenarios such as inventory systems, databases, and application state management.
These labs focus on how objects organize related data and how programs reason about that structure. Working with keys and values builds an understanding of how JavaScript represents complex information, laying the foundation for handling APIs, configuration objects, and real application data models.