The first line in the code editor starts with double slash //:
// Chapter 1, First JS program
This is a comment line.
Comments are text among your code but ignored when your program runs.
Using comments you can add annotations in your program to clarify the purpose of your code, or disable a piece of code that you don't want to execute for now.
One-line comments start with
//. Everything to the right of the double slash becomes "commented out".
// to the beginning of line 2, like this:
// Chapter 1, First JS program // console.log('Hello, Buzz Coder!'); console.log(); console.log("Hello, CodeCraft!");
Click 'run' and you'll see the console result. The message
Hello, Buzz Coder! disappears because its
console.log() statement has been commented out, and the computer no longer reads it.
The very first line of every CodeCraft file becomes the name of the file by default. You can see it shown in the file name box at the top right corner of your screen. Whenever you start a new file, it's a good idea to give it a name as a comment to indicate its content.
Multi-line comment is often used in JS to disable a piece of code that we don't want to execute for now.
*/ to enclose all the codes you want to comment out. See in the example:
/* this is a multi-line comment */