console.log and comments · console.log y comentarios
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Esta página necesita un navegador reciente (con soporte para SharedArrayBuffer). Por favor, actualiza Chrome, Edge, Firefox o Safari a la última versión.
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.
Español
El lenguaje de la web
- JavaScript se ejecuta dentro de cada navegador web. Permite que las páginas hagan cosas — botones, juegos, mapas, chats.
console.log(...)imprime un mensaje en la consola, una ventana para la salida de texto.- Todo lo que está después de
//es un comentario. JavaScript lo ignora; es una nota para los humanos que leen el código.
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.
Español
Imprimir texto, números o ambos
- El texto va dentro de comillas:
"hello". Los números no:42. - Pasa varios elementos separados por comas — se imprimen en una sola línea, con un espacio entre ellos.
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.
Español
Cuidado
- El texto necesita comillas.
console.log(Hello)es un error — JavaScript busca algo llamadoHello. - Termina cada instrucción con punto y coma
;. Es una buena costumbre, incluso donde JavaScript te lo perdonaría.
English
Common mistakes
console.log(...)prints; text needs quotes.//starts a comment.
Español
Errores comunes
console.log(...)imprime; el texto necesita comillas.//inicia un comentario.
English
Now you try
- Use
console.log(...)to print. - Press Run to see the output, then Check answer.
Español
Ahora tú intentas
- Usa
console.log(...)para imprimir. - Presiona Run (Ejecutar) para ver la salida, luego Check answer (Verificar respuesta).
Use console.log(...) to print the word Hello. · Usa console.log(...) para imprimir la palabra Hello.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.
Print Red, Green and · y Blue, one per line, in that order. · Imprime Red, Green y Blue, uno por línea, en ese orden.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.
Print the result of 5 + 3 (it is 8). · Imprime el resultado de 5 + 3 (es 8).
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.