Variables and DECLARE · Biến và DECLARE
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Trang này cần trình duyệt gần đây (hỗ trợ SharedArrayBuffer). Vui lòng cập nhật Chrome, Edge, Firefox hoặc Safari lên phiên bản mới nhất.
English
A variable stores one value
- A variable has a name and holds one value you can change.
- The 2026 guide writes names in mixed case, starting with a letter:
NumberOfPlayersornumberOfPlayers. - These lessons use a capital first letter, the same shape as the guide's own examples.
Tiếng Việt
Một biến lưu một giá trị
- Một biến có tên và chứa một giá trị bạn có thể thay đổi.
- Hướng dẫn 2026 viết tên theo chữ hoa thường, bắt đầu bằng chữ cái:
NumberOfPlayershoặcnumberOfPlayers. - Các bài học này sử dụng chữ cái đầu viết hoa, cùng kiểu với các ví dụ của chính hướng dẫn.
DECLARE Counter : INTEGER
Counter ← 0
Counter ← Counter + 1
OUTPUT Counter
English
DECLARE, then the arrow
DECLARE Counter : INTEGERcreates the variable and names its type.- The assignment operator is
←. It stores the value on the right. =is not how you store a value.=means "is equal to" inside a test.
Tiếng Việt
DECLARE, sau đó là mũi tên
DECLARE Counter : INTEGERtạo biến và đặt tên cho kiểu của nó.- Toán tử gán là
←. Nó lưu giá trị ở bên phải. =không phải là cách bạn lưu một giá trị.=có nghĩa "bằng" trong một phép kiểm tra.
DECLARE Score : INTEGER
Score ← 40
Score ← Score + 2
OUTPUT Score
English
Watch out
- Declare a variable before you use it.
- An identifier starts with a letter. Digits may follow. The guide also allows
_.
Tiếng Việt
Lưu ý
- Khai báo biến trước khi sử dụng nó.
- Một định danh bắt đầu bằng chữ cái. Các số có thể theo sau. Hướng dẫn cũng cho phép
_.
English
Common mistakes
Counter ← 1stores 1.Counter = 1is not an assignment.- One variable holds one value. Assigning again replaces it.
Tiếng Việt
Lỗi thường gặp
Counter ← 1lưu 1.Counter = 1không phải là phép gán.- Một biến chỉ chứa một giá trị. Gán lại sẽ thay thế nó.
English
Now you try
- Declare an integer, store a value with
←, and output it.
Tiếng Việt
Bây giờ bạn thử
- Khai báo số nguyên, lưu giá trị bằng
←, và xuất ra nó.
Declare Total as an INTEGER, store 8, and output it. · KhHIẾN Total là một INTEGER, lưu 8, và xuất ra nó.
Click Run to see the output here. · Nhấn Chạy để xem kết quả ở đây.
Declare Counter as an INTEGER. Start it at 0, add 1, and output it. · KhHIẾN Counter là một INTEGER. Bắt đầu nó ở 0, thêm 1, và xuất ra nó.
Click Run to see the output here. · Nhấn Chạy để xem kết quả ở đây.