Hello, JavaScript!

Write and run your first JavaScript program with console.log.

javascript·~10 minutes·Lesson 1 of 12
Print text to the output with console.logUnderstand strings use single or double quotesRun your code and see the result

Every programming journey starts the same way: by making the computer say "hello." You're going to write one line of code, click Run, and watch your message appear in the output panel.

What you'll learn

  • Print text with console.log(...)
  • Write strings with "double" or 'single' quotes
  • Run your code and read the output

Instructions

Write a single line of JavaScript that prints exactly:

Hello, World!

Then click Run to execute it. When your output matches, click Check My Work to complete the lesson.

Key concepts

console.log prints to the output

console.log(...) is the bread-and-butter way to send text to the output panel. Whatever you put inside the parentheses gets printed, followed by a newline.

console.log("Hi there");

The semicolon at the end is optional in most cases — JavaScript will insert one for you — but writing it is a good habit.

Strings live inside quotes

Any sequence of characters wrapped in "double quotes" or 'single quotes' is a string. Both kinds work the same way.

console.log("It's a fine day");
console.log('She said "hi"');

Use whichever quote style keeps the inside of the string readable without needing to escape.

Hints

  1. You only need one line of code.
  2. Which function prints text to the output?
  3. console.log("Hello, World!");