console.log and comments · console.log và comment
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
The language of the web
- JavaScript runs inside every web browser. It makes pages do things — buttons, games, maps, chat.
console.log(...)prints a message to the console, a window for text output.- Anything after
//is a comment. JavaScript ignores it — it is a note for humans reading the code.
Tiếng Việt
Ngôn ngữ của web
- JavaScript chạy bên trong mọi trình duyệt web. Nó khiến các trang làm việc — nút bấm, trò chơi, bản đồ, chat.
console.log(...)in một tin nhắn ra console (bảng điều khiển), một cửa sổ dành cho văn bản đầu ra.- Mọi thứ sau
//là một comment (phản hồi). JavaScript bỏ qua nó — đó là ghi chú dành cho người đọc mã nguồn.
console.log("Hello, world!"); // → Hello, world!
// this whole line is a comment — it does nothing
English
Print text, numbers, or both
- Text goes inside quotes:
"hello". Numbers do not:42. - Pass several items separated by commas — they print on one line, with a space between.
Tiếng Việt
In văn bản, số, hoặc cả hai
- Văn bản đi vào trong dấu ngoặc kép:
"hello". Số thì không:42. - Truyền nhiều mục cách nhau bởi dấu phẩy — chúng được in trên một dòng, với một khoảng trắng giữa các mục.
console.log("Score:", 42); // → Score: 42
console.log(3 + 4); // → 7
English
Watch out
- Text needs quotes.
console.log(Hello)is an error — JavaScript hunts for something namedHello. - End each statement with a semicolon
;. It is a good habit, even where JavaScript would forgive you.
Tiếng Việt
Lưu ý
- Văn bản cần dấu ngoặc kép.
console.log(Hello)là một lỗi — JavaScript tìm kiếm một thứ gì đó có tên làHello. - Kết thúc mỗi câu lệnh bằng dấu chấm phẩy
;. Đó là thói quen tốt, ngay cả nơi JavaScript có thể tha lỗi cho bạn.
English
Common mistakes
console.log(...)prints; text needs quotes.//starts a comment.
Tiếng Việt
Lỗi thường gặp
console.log(...)in ra; văn bản cần dấu ngoặc kép.//bắt đầu một comment.
English
Now you try
- Use
console.log(...)to print. - Press Run to see the output, then Check answer.
Tiếng Việt
Bây giờ bạn thử
- Sử dụng
console.log(...)để in ra. - Nhấn Chạy để xem kết quả, sau đó nhấn Kiểm tra đáp án.
Use console.log(...) to print the word Hello. · Sử dụng console.log(...) để in ra từ Hello.
Click Run to see the output here. · Nhấn Chạy để xem kết quả ở đây.
Print Red, Green and Blue, one per line, in that order. · In Red, Green và Blue, mỗi cái một dòng, theo thứ tự đó.
Click Run to see the output here. · Nhấn Chạy để xem kết quả ở đây.
Print the result of 5 + 3 (it is 8). · In kết quả của 5 + 3 (đó là 8).
Click Run to see the output here. · Nhấn Chạy để xem kết quả ở đây.