← Projects

Inventory tracker

Read and update a small collection, then count its contents without changing the original. Preview: a proposed inventory and its numeric total.

Runs here · Luau

Loading project… · Milestone 1 of 2

Propose updated stock

Implement addStock(stock, name, amount). Clone stock with table.clone, add amount to the named entry (use 0 when missing), and return { stock = nextStock, original = stock }. Do not change the supplied stock; the checker observes both tables. Keep return addStock.

Acceptance criteria

  • Implement addStock(stock, name, amount). Clone stock with table.clone, add amount to the named entry (use 0 when missing), and return { stock = nextStock, original = stock }. Do not change the supplied stock; the checker observes both tables. Keep return addStock.
  • Handle the visible inputs and additional boundary cases.
Project milestones
  1. Available to preview
  2. Available to preview
Prerequisites
Optional extension

Add a read-only report of zero-stock entries. Keep the counting function reusable.

Project notes and references

Educational example. Review and redesign it for the requirements of a real project.

Your learning source is private by default. Completing this project does not grant a professional or staff role.

Luau syntax ↗

Luau standard library ↗

Luau keyword highlighting · Ctrl/⌘ + Enter: Run · Esc: leave editor

Run experiment shows actual behavior. Check milestone uses the acceptance criteria and records trusted progress.

Output

Your output will appear here.

Visible examples

Existing · { { keys = 2 }, "keys", 3 } → { stock = { keys = 5 }, original = { keys = 2 } }

New · { { keys = 2 }, "maps", 1 } → { stock = { keys = 2, maps = 1 }, original = { keys = 2 } }

Sharing is an explicit choice in your portfolio editor. Label exported work “Learning project”; existing publication rules apply.