Register to get access to free programming courses with interactive exercises

Hello, World! JavaScript fundamentals

As usual, we'll start by writing a "Hello, World!" program. The program will print the text. To print something, you need to give computer a special command. In JavaScript, we use console.log().

Hello World

console.log('Hello, World!');
// => Hello, World!

We will sometimes show the result of running code lines using the comments, like this: => RESULT. For example, // => 4.


The source code files may contain comments in addition to the code. This is non-executable line(s) of text that is required for programmers to take notes. They're used to describe how the code works and what errors need to be fixed, as well as to remind you to add anything later.

// Delete the line below after the registration feature is implemented

Comments in JavaScript are of two kinds.

Single line comments start with //. Any text or symbols that follow, won't be evaluated or executed. A comment can take up the whole line or several lines:

// For Winterfell!
// For Lanisters!

or can follow some code on the same line:

console.log('I am the King'); // For Lannisters!

Multiline comments start with /* and end with */.

  The night is dark and
  full of terrors.
console.log('I am the King');

Such comments usually clarify the purpose of pieces of code and build its documentation.

Recommended materials

  1. About "Hello, World!"

Hexlet Experts

Are there any more questions? Ask them in the Discussion section.

The Hexlet support team or other students will answer you.

About Hexlet learning process

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

<span class="translation_missing" title="translation missing:">Bookmate</span>
<span class="translation_missing" title="translation missing:">Healthsamurai</span>
<span class="translation_missing" title="translation missing:">Dualboot</span>
<span class="translation_missing" title="translation missing:">Abbyy</span>
Suggested learning programs
Frontend Developer icon
Development of front-end components for web applications
start anytime 10 months

Use Hexlet to the fullest extent!

  • Ask questions about the lesson
  • Test your knowledge in quizzes
  • Practice in your browser
  • Track your progress

Sign up or sign in

By sending this form, you agree to our Personal Policy and Service Conditions
Toto Image

Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.