console.log and comments · console.log dan komentar
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Halaman ini memerlukan browser terbaru (dengan dukungan SharedArrayBuffer). Silakan perbarui Chrome, Edge, Firefox, atau Safari ke versi terbaru.
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.
Bahasa Indonesia
Bahasa web
- JavaScript berjalan di dalam setiap browser web. Ia membuat halaman melakukan sesuatu — tombol, game, peta, obrolan.
console.log(...)mencetak pesan ke konsol, jendela untuk teks keluaran.- Apa pun setelah
//adalah komentar. JavaScript mengabaikannya — itu adalah catatan untuk manusia yang membaca kode.
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.
Bahasa Indonesia
Cetak teks, angka, atau keduanya
- Teks masuk di dalam tanda kutip:
"hello". Angka tidak:42. - Lintaskan beberapa item dipisahkan koma — mereka dicetak pada satu baris, dengan spasi di antaranya.
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.
Bahasa Indonesia
Hati-hati
- Teks membutuhkan tanda kutip.
console.log(Hello)adalah kesalahan — JavaScript mencari sesuatu yang disebutHello. - Akhiri setiap pernyataan dengan titik koma
;. Itu adalah kebiasaan baik, bahkan di tempat JavaScript akan mengampuni Anda.
English
Common mistakes
console.log(...)prints; text needs quotes.//starts a comment.
Bahasa Indonesia
Kesalahan umum
console.log(...)mencetak; teks butuh tanda kutip.//memulai komentar.
English
Now you try
- Use
console.log(...)to print. - Press Run to see the output, then Check answer.
Bahasa Indonesia
Sekarang Anda coba
- Gunakan
console.log(...)untuk mencetak. - Tekan Run untuk melihat output, lalu Check answer.
Use console.log(...) to print the word Hello. · Gunakan console.log(...) untuk mencetak kata Hello.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.
Print Red, Green and Blue, one per line, in that order. · Cetak Red, Green dan Blue, satu per baris, sesuai urutan tersebut.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.
Print the result of 5 + 3 (it is 8). · Cetak hasil dari 5 + 3 (yaitu 8).
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.