Variables
Learn how to store and work with data using variables in natural language.
User input allows you to get values from users while your program is running. The browser will show a prompt dialog asking for input.
Supported types: number, boolean, string (default)
If no type is specified, the input is treated as a string. For boolean input, enter "true" or "True" (case-insensitive).
Numbers
Integers and decimal numbers are supported.
Text (Strings)
Text must be enclosed in double quotes.
Boolean (True/False)
Use `true` or `false` (lowercase).
Expressions
Variables can be assigned the result of expressions.
✓ Good Names
✗ Avoid
Naming Rules
- • Use descriptive names that explain the variable's purpose
- • Use lowercase letters and underscores (snake_case)
- • Start with a letter, not a number
- • Avoid spaces and special characters
- • Use boolean names that read like questions (is_valid, has_data)
Reassignment
Simply assign a new value using the same syntax.
Mathematical Updates
Use the variable in expressions to update based on its current value.
Increment and Decrement
Special commands for adding or subtracting 1.
Global Variables
Variables declared outside blocks can be used anywhere in the program.
Block Variables
Variables declared inside blocks (if, for, while) are only available within that block.
Initialize variables before use
Always assign a value when declaring a variable to avoid errors.
Use meaningful names
Choose names that make your code self-documenting and easy to understand.
Be consistent with naming
Use the same naming pattern throughout your program (e.g., always use snake_case).
Group related variables
Declare related variables near each other for better code organization.
Counter Variables
Track how many times something happens.
Accumulator Variables
Build up a result over multiple operations.
Flag Variables
Track true/false states or conditions.
Temporary Variables
Store intermediate values during calculations.