Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Commenting in JavaScript | JavaScript syntax
Introduction to JavaScript (staging)
course content

Course Content

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

1. Introduction
2. JavaScript syntax
3. Data Types and Variables

Commenting in JavaScript

JavaScript Comments:

Comments are used to clear the code and make the program more coherent for developers. A single-line comment is used to comment out one line or a part of one line and a multi-line comment is used to comment out a block of code. In programming, comments can also be used to avoid some code lines from being executed. This is useful for testing. Multi-line comments are generally used for the formal way to represent the code

Comment vs Comment Out:

Commenting out means that you taking a part of the code and closing it with JavaScript comment symbols. they do not execute by the web browser, which means that they won’t be displayed. Check out the example of commenting out a single line below.

1234
//const SECONDS = 60; console.log(SECONDS); const MINUTES = 60; console.log(MINUTES)
copy

We will get the error for the variable SECONDS because that line is commented out. But we got the desired output for the variable MINUTES.

Single-line Comments

Single-line comments are used to comment out a part of a line or a full line of code. You can use it for explaining the code or testing the code.

12345678
let n = 50; console.log(n); // let numberOfStudents = 10; // console.log(numberOfStudents); let myAge = 25; console.log(myAge);
copy

We only got the outputs for the variables n and myAge but not for numberOfStudents because it was commented.

Task

In the following given code, we do not need the wearings variable. Your task is to comment out this variable as well as the line which displays the output for this variable.

Task

In the following given code, we do not need the wearings variable. Your task is to comment out this variable as well as the line which displays the output for this variable.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 14
toggle bottom row

Commenting in JavaScript

JavaScript Comments:

Comments are used to clear the code and make the program more coherent for developers. A single-line comment is used to comment out one line or a part of one line and a multi-line comment is used to comment out a block of code. In programming, comments can also be used to avoid some code lines from being executed. This is useful for testing. Multi-line comments are generally used for the formal way to represent the code

Comment vs Comment Out:

Commenting out means that you taking a part of the code and closing it with JavaScript comment symbols. they do not execute by the web browser, which means that they won’t be displayed. Check out the example of commenting out a single line below.

1234
//const SECONDS = 60; console.log(SECONDS); const MINUTES = 60; console.log(MINUTES)
copy

We will get the error for the variable SECONDS because that line is commented out. But we got the desired output for the variable MINUTES.

Single-line Comments

Single-line comments are used to comment out a part of a line or a full line of code. You can use it for explaining the code or testing the code.

12345678
let n = 50; console.log(n); // let numberOfStudents = 10; // console.log(numberOfStudents); let myAge = 25; console.log(myAge);
copy

We only got the outputs for the variables n and myAge but not for numberOfStudents because it was commented.

Task

In the following given code, we do not need the wearings variable. Your task is to comment out this variable as well as the line which displays the output for this variable.

Task

In the following given code, we do not need the wearings variable. Your task is to comment out this variable as well as the line which displays the output for this variable.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 14
toggle bottom row

Commenting in JavaScript

JavaScript Comments:

Comments are used to clear the code and make the program more coherent for developers. A single-line comment is used to comment out one line or a part of one line and a multi-line comment is used to comment out a block of code. In programming, comments can also be used to avoid some code lines from being executed. This is useful for testing. Multi-line comments are generally used for the formal way to represent the code

Comment vs Comment Out:

Commenting out means that you taking a part of the code and closing it with JavaScript comment symbols. they do not execute by the web browser, which means that they won’t be displayed. Check out the example of commenting out a single line below.

1234
//const SECONDS = 60; console.log(SECONDS); const MINUTES = 60; console.log(MINUTES)
copy

We will get the error for the variable SECONDS because that line is commented out. But we got the desired output for the variable MINUTES.

Single-line Comments

Single-line comments are used to comment out a part of a line or a full line of code. You can use it for explaining the code or testing the code.

12345678
let n = 50; console.log(n); // let numberOfStudents = 10; // console.log(numberOfStudents); let myAge = 25; console.log(myAge);
copy

We only got the outputs for the variables n and myAge but not for numberOfStudents because it was commented.

Task

In the following given code, we do not need the wearings variable. Your task is to comment out this variable as well as the line which displays the output for this variable.

Task

In the following given code, we do not need the wearings variable. Your task is to comment out this variable as well as the line which displays the output for this variable.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

JavaScript Comments:

Comments are used to clear the code and make the program more coherent for developers. A single-line comment is used to comment out one line or a part of one line and a multi-line comment is used to comment out a block of code. In programming, comments can also be used to avoid some code lines from being executed. This is useful for testing. Multi-line comments are generally used for the formal way to represent the code

Comment vs Comment Out:

Commenting out means that you taking a part of the code and closing it with JavaScript comment symbols. they do not execute by the web browser, which means that they won’t be displayed. Check out the example of commenting out a single line below.

1234
//const SECONDS = 60; console.log(SECONDS); const MINUTES = 60; console.log(MINUTES)
copy

We will get the error for the variable SECONDS because that line is commented out. But we got the desired output for the variable MINUTES.

Single-line Comments

Single-line comments are used to comment out a part of a line or a full line of code. You can use it for explaining the code or testing the code.

12345678
let n = 50; console.log(n); // let numberOfStudents = 10; // console.log(numberOfStudents); let myAge = 25; console.log(myAge);
copy

We only got the outputs for the variables n and myAge but not for numberOfStudents because it was commented.

Task

In the following given code, we do not need the wearings variable. Your task is to comment out this variable as well as the line which displays the output for this variable.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 14
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt