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()
.
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
console.log(10);
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');
https://replit.com/@hexlet/helloworld
Such comments usually clarify the purpose of pieces of code and build its documentation.
The Hexlet support team or other students will answer you.
Programming courses for beginners and experienced developers. Start training for free
Our graduates work in companies:
Sign up or sign in
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.