Insert a fabric swatch
Before you start this beginner track
Variables, loops, and sequences. Lua sequence indexes start at one.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Predict the result.
What is the final fabric inventory?
local fabrics = {"linen", "wool"}table.insert(fabrics, 2, "silk")local inventory = table.concat(fabrics, ", ")print(inventory)Each mission is a standalone Lua 5.4 script with standard libraries. Tables used as sequences have consecutive integer keys starting at 1 and no gaps. All string examples use ASCII text.
Review the lesson
Lua uses tables for ordered sequences as well as other data structures. table.insert can place a new item at a chosen position and shift later items along. The sequence begins at position 1. table.concat joins these string values into a readable inventory while preserving their order.