Lesson 2 of 15
Variables & Types
Variables & Types
Lua is dynamically typed. Variables are declared with local:
local name = "Alice"
local age = 30
local active = true
local nothing = nil
Lua has these basic types: nil, boolean, number, string, table, and function.
Use type() to check a value's type:
print(type(42)) -- number
print(type("hello")) -- string
print(type(true)) -- boolean
print(type(nil)) -- nil
Your Task
Create variables for a name (string), an age (number), and print them on separate lines.
JS Transpiler loading...
Loading...
Click "Run" to execute your code.